1.1.8 • Published 5 years ago

yup-of-json v1.1.8

Weekly downloads
-
License
MIT
Repository
-
Last release
5 years ago

of JSON

Convert JSON to a yup schema

Usage

import parse from "yup-of-json";

Example

  • JSON Schema
{
  "addresses": {
    "raw": "Kukuroo Mountain"
  },
  "age": 14,
  "hunter": true,
  "name": "Killua Zoldyck",
  "role": null,
  "tags": [
    {
      "label": "cute"
    }
  ]
}
  • Result
yup
  .object()
  .shape({
    addresses: yup
      .object()
      .shape({ raw: yup.string().required() })
      .noUnknown()
      .required(),
    age: yup.number().required(),
    hunter: yup.boolean().nullable(),
    name: yup.string().required(),
    role: yup.mixed().nullable(),
    tags: yup
      .array()
      .of(
        yup
          .object()
          .shape({ label: yup.string().required() })
          .noUnknown()
          .required()
      )
      .defined(),
  })
  .noUnknown()
  .required();

License

This project is distributed under the MIT license

1.1.8

5 years ago

1.1.7

5 years ago

1.1.6

5 years ago

1.1.5

5 years ago

1.1.4

5 years ago

1.1.2

5 years ago

1.1.1

5 years ago

1.1.0

5 years ago

1.0.8

5 years ago

1.0.7

5 years ago

1.0.6

5 years ago

1.0.5

5 years ago

1.0.4

5 years ago

1.0.3

5 years ago

1.0.2

5 years ago

1.0.1

5 years ago

1.0.0

5 years ago