Schema is a TypeScript representation of a correct JSON Typedef schema.
The JSON Typedef specification allows schemas to take on one of eight forms. Each of those forms has its own type in this module; Schema is simply a union of each of those eight types.
SchemaFormDiscriminator represents schemas of the discriminator form.
SchemaFormElements represents schemas of the elements form.
SchemaFormEmpty represents schemas of the empty form.
SchemaFormEnum represents schemas of the enum form.
SchemaFormProperties represents schemas of the properties form.
SchemaFormRef represents schemas of the ref form.
SchemaFormType represents schemas of the type form.
SchemaFormValues represents schemas of the values form.
Type represents the legal values of the "type" keyword in JSON Typedef.
isDiscriminatorForm checks whether some Schema is of the values form.
The schema to validate
isElementsForm checks whether some Schema is of the elements form.
The schema to validate
isEmptyForm checks whether some Schema is of the empty form.
The schema to validate
isEnumForm checks whether some Schema is of the enum form.
The schema to validate
isPropertiesForm checks whether some Schema is of the properties form.
The schema to validate
isRefForm checks whether some Schema is of the ref form.
The schema to validate
isSchema checks whether some piece of JSON data has the shape of a JSON Typedef Schema.
This function only looks at the "shape" of data: it just makes sure all property names and types are valid, and that the data takes on one of the eight JSON Typedef forms.
If an object returned from JSON.parse
passes both isSchema and
isValidSchema, then it is a correct JSON Typedef schema.
The data to check
isTypeForm checks whether some Schema is of the type form.
The schema to validate
isValidSchema checks whether some Schema is correct, according to the syntax rules of JSON Typedef.
In particular, isValidSchema verifies that:
properties
and optionalProperties
of a schema never share
properties,mapping
are of the properties form,mapping
never re-specify the discriminator
propertyIf an object returned from JSON.parse
passes both isSchema and
isValidSchema, then it is a correct JSON Typedef schema.
The schema to validate
The schema to consider as the "root" schema. If undefined,
schema
will be used as the root. This is usually what you want to do.
isPropertiesForm checks whether some Schema is of the values form.
The schema to validate
Generated using TypeDoc
Module schema provides code to safely handle JSON Typedef schemas.
JSON Typedef schemas are represented in this module with Schema, and you can check if a JSON object is a correct schema by using isSchema and isValidSchema.