Skip to content

Latest commit

 

History

History
1255 lines (934 loc) · 55.7 KB

API.md

File metadata and controls

1255 lines (934 loc) · 55.7 KB

Functions

ArraySchema([options])ArraySchema

Represents a ArraySchema.

items(items)FluentSchema

This keyword determines how child instances validate for arrays, and does not directly validate the immediate instance itself. If "items" is a schema, validation succeeds if all elements in the array successfully validate against that schema. If "items" is an array of schemas, validation succeeds if each element of the instance validates against the schema at the same position, if any. Omitting this keyword has the same behavior as an empty schema.

reference

additionalItems(items)FluentSchema

This keyword determines how child instances validate for arrays, and does not directly validate the immediate instance itself.

reference

contains(value)FluentSchema

An array instance is valid against "contains" if at least one of its elements is valid against the given schema.

reference

uniqueItems(boolean)FluentSchema

If this keyword has boolean value false, the instance validates successfully. If it has boolean value true, the instance validates successfully if all of its elements are unique. Omitting this keyword has the same behavior as a value of false.

reference

minItems(min)FluentSchema

An array instance is valid against "minItems" if its size is greater than, or equal to, the value of this keyword. Omitting this keyword has the same behavior as a value of 0.

reference

maxItems(max)FluentSchema

An array instance is valid against "minItems" if its size is greater than, or equal to, the value of this keyword. Omitting this keyword has the same behavior as a value of 0.

reference

BaseSchema([options])BaseSchema

Represents a BaseSchema.

id(id)BaseSchema

It defines a URI for the schema, and the base URI that other URI references within the schema are resolved against.

reference

title(title)BaseSchema

It can be used to decorate a user interface with information about the data produced by this user interface. A title will preferably be short.

reference

description(description)BaseSchema

It can be used to decorate a user interface with information about the data produced by this user interface. A description provides explanation about the purpose of the instance described by the schema.

reference

examples(examples)BaseSchema

The value of this keyword MUST be an array. There are no restrictions placed on the values within the array.

reference

ref(ref)BaseSchema

The value must be a valid id e.g. #properties/foo

enum(values)BaseSchema

The value of this keyword MUST be an array. This array SHOULD have at least one element. Elements in the array SHOULD be unique.

reference

const(value)BaseSchema

The value of this keyword MAY be of any type, including null.

reference

default(defaults)BaseSchema

There are no restrictions placed on the value of this keyword.

reference

readOnly(isReadOnly)BaseSchema

The value of readOnly can be left empty to indicate the property is readOnly. It takes an optional boolean which can be used to explicitly set readOnly true/false.

reference

writeOnly(isWriteOnly)BaseSchema

The value of writeOnly can be left empty to indicate the property is writeOnly. It takes an optional boolean which can be used to explicitly set writeOnly true/false.

reference

deprecated(isDeprecated)BaseSchema

The value of deprecated can be left empty to indicate the property is deprecated. It takes an optional boolean which can be used to explicitly set deprecated true/false.

reference

required()FluentSchema

Required has to be chained to a property: Examples:

  • S.prop('prop').required()
  • S.prop('prop', S.number()).required()
  • S.required(['foo', 'bar'])

reference

not(not)BaseSchema

This keyword's value MUST be a valid JSON Schema. An instance is valid against this keyword if it fails to validate successfully against the schema defined by this keyword.

reference

anyOf(schemas)BaseSchema

It MUST be a non-empty array. Each item of the array MUST be a valid JSON Schema.

reference

allOf(schemas)BaseSchema

It MUST be a non-empty array. Each item of the array MUST be a valid JSON Schema.

reference

oneOf(schemas)BaseSchema

It MUST be a non-empty array. Each item of the array MUST be a valid JSON Schema.

reference

ifThen(ifClause, thenClause)BaseSchema

This validation outcome of this keyword's subschema has no direct effect on the overall validation result. Rather, it controls which of the "then" or "else" keywords are evaluated. When "if" is present, and the instance successfully validates against its subschema, then validation succeeds against this keyword if the instance also successfully validates against this keyword's subschema.

ifThenElse(ifClause, thenClause, elseClause)BaseSchema

When "if" is present, and the instance fails to validate against its subschema, then validation succeeds against this keyword if the instance successfully validates against this keyword's subschema.

raw(fragment)BaseSchema

Because the differences between JSON Schemas and Open API (Swagger) it can be handy to arbitrary modify the schema injecting a fragment

  • Examples:
  • S.number().raw({ nullable:true })
  • S.string().format('date').raw({ formatMaximum: '2020-01-01' })
valueOf([options])object

It returns all the schema values

BooleanSchema([options])StringSchema

Represents a BooleanSchema.

S([options])S

Represents a S.

string()StringSchema

Set a property to type string

reference

number()NumberSchema

Set a property to type number

reference

integer()IntegerSchema

Set a property to type integer

reference

boolean()BooleanSchema

Set a property to type boolean

reference

array()ArraySchema

Set a property to type array

reference

object()ObjectSchema

Set a property to type object

reference

null()NullSchema

Set a property to type null

reference

mixed(types)MixedSchema

A mixed schema is the union of multiple types (e.g. ['string', 'integer']

raw(fragment)BaseSchema

Because the differences between JSON Schemas and Open API (Swagger) it can be handy to arbitrary modify the schema injecting a fragment

  • Examples:
  • S.raw({ nullable:true, format: 'date', formatMaximum: '2020-01-01' })
  • S.string().format('date').raw({ formatMaximum: '2020-01-01' })
IntegerSchema([options])NumberSchema

Represents a NumberSchema.

MixedSchema([options])StringSchema

Represents a MixedSchema.

NullSchema([options])StringSchema

Represents a NullSchema.

null()FluentSchema

Set a property to type null

reference

NumberSchema([options])NumberSchema

Represents a NumberSchema.

minimum(min)FluentSchema

It represents an inclusive lower limit for a numeric instance.

reference

exclusiveMinimum(min)FluentSchema

It represents an exclusive lower limit for a numeric instance.

reference

maximum(max)FluentSchema

It represents an inclusive upper limit for a numeric instance.

reference

exclusiveMaximum(max)FluentSchema

It represents an exclusive upper limit for a numeric instance.

reference

multipleOf(multiple)FluentSchema

It's strictly greater than 0.

reference

ObjectSchema([options])StringSchema

Represents a ObjectSchema.

id(id)

It defines a URI for the schema, and the base URI that other URI references within the schema are resolved against. Calling id on an ObjectSchema will alway set the id on the root of the object rather than in its "properties", which differs from other schema types.

reference

additionalProperties(value)FluentSchema

This keyword determines how child instances validate for objects, and does not directly validate the immediate instance itself. Validation with "additionalProperties" applies only to the child values of instance names that do not match any names in "properties", and do not match any regular expression in "patternProperties". For all such properties, validation succeeds if the child instance validates against the "additionalProperties" schema. Omitting this keyword has the same behavior as an empty schema.

reference

maxProperties(max)FluentSchema

An object instance is valid against "maxProperties" if its number of properties is less than, or equal to, the value of this keyword.

reference

minProperties(min)FluentSchema

An object instance is valid against "minProperties" if its number of properties is greater than, or equal to, the value of this keyword.

reference

patternProperties(opts)FluentSchema

Each property name of this object SHOULD be a valid regular expression, according to the ECMA 262 regular expression dialect. Each property value of this object MUST be a valid JSON Schema. This keyword determines how child instances validate for objects, and does not directly validate the immediate instance itself. Validation of the primitive instance type against this keyword always succeeds. Validation succeeds if, for each instance name that matches any regular expressions that appear as a property name in this keyword's value, the child instance for that name successfully validates against each schema that corresponds to a matching regular expression.

reference

dependencies(opts)FluentSchema

This keyword specifies rules that are evaluated if the instance is an object and contains a certain property. This keyword's value MUST be an object. Each property specifies a dependency. Each dependency value MUST be an array or a valid JSON Schema. If the dependency value is a subschema, and the dependency key is a property in the instance, the entire instance must validate against the dependency value. If the dependency value is an array, each element in the array, if any, MUST be a string, and MUST be unique. If the dependency key is a property in the instance, each of the items in the dependency value must be a property that exists in the instance.

reference

dependentRequired(opts)FluentSchema

The value of "properties" MUST be an object. Each dependency value MUST be an array. Each element in the array MUST be a string and MUST be unique. If the dependency key is a property in the instance, each of the items in the dependency value must be a property that exists in the instance.

reference

dependentSchemas(opts)FluentSchema

The value of "properties" MUST be an object. The dependency value MUST be a valid JSON Schema. Each dependency key is a property in the instance and the entire instance must validate against the dependency value.

reference

propertyNames(value)FluentSchema

If the instance is an object, this keyword validates if every property name in the instance validates against the provided schema. Note the property name that the schema is testing will always be a string.

reference

prop(name, props)FluentSchema

The value of "properties" MUST be an object. Each value of this object MUST be a valid JSON Schema.

reference

only(properties)ObjectSchema

Returns an object schema with only a subset of keys provided. If called on an ObjectSchema with an $id, it will be removed and the return value will be considered a new schema.

without(properties)ObjectSchema

Returns an object schema without a subset of keys provided. If called on an ObjectSchema with an $id, it will be removed and the return value will be considered a new schema.

definition(name, props)FluentSchema

The "definitions" keywords provides a standardized location for schema authors to inline re-usable JSON Schemas into a more general schema. There are no restrictions placed on the values within the array.

reference

RawSchema(schema)FluentSchema

Represents a raw JSON Schema that will be parsed

StringSchema([options])StringSchema

Represents a StringSchema.

minLength(min)StringSchema

A string instance is valid against this keyword if its length is greater than, or equal to, the value of this keyword. The length of a string instance is defined as the number of its characters as defined by RFC 7159 [RFC7159].

reference

maxLength(max)StringSchema

A string instance is valid against this keyword if its length is less than, or equal to, the value of this keyword. The length of a string instance is defined as the number of its characters as defined by RFC 7159 [RFC7159].

reference

format(format)StringSchema

A string value can be RELATIVE_JSON_POINTER, JSON_POINTER, UUID, REGEX, IPV6, IPV4, HOSTNAME, EMAIL, URL, URI_TEMPLATE, URI_REFERENCE, URI, TIME, DATE,

reference

pattern(pattern)StringSchema

This string SHOULD be a valid regular expression, according to the ECMA 262 regular expression dialect. A string instance is considered valid if the regular expression matches the instance successfully.

reference

contentEncoding(encoding)StringSchema

If the instance value is a string, this property defines that the string SHOULD be interpreted as binary data and decoded using the encoding named by this property. RFC 2045, Sec 6.1 [RFC2045] lists the possible values for this property.

reference

contentMediaType(mediaType)StringSchema

The value of this property must be a media type, as defined by RFC 2046 [RFC2046]. This property defines the media type of instances which this schema defines.

reference

ArraySchema([options]) ⇒ ArraySchema

Represents a ArraySchema.

Kind: global function

Param Type Default Description
[options] Object Options
[options.schema] StringSchema Default schema
[options.generateIds] boolean false generate the id automatically e.g. #properties.foo

items(items) ⇒ FluentSchema

This keyword determines how child instances validate for arrays, and does not directly validate the immediate instance itself. If "items" is a schema, validation succeeds if all elements in the array successfully validate against that schema. If "items" is an array of schemas, validation succeeds if each element of the instance validates against the schema at the same position, if any. Omitting this keyword has the same behavior as an empty schema.

reference

Kind: global function

Param Type
items FluentSchema | Array.<FluentSchema>

additionalItems(items) ⇒ FluentSchema

This keyword determines how child instances validate for arrays, and does not directly validate the immediate instance itself.

reference

Kind: global function

Param Type
items FluentSchema | boolean

contains(value) ⇒ FluentSchema

An array instance is valid against "contains" if at least one of its elements is valid against the given schema.

reference

Kind: global function

Param Type
value FluentSchema

uniqueItems(boolean) ⇒ FluentSchema

If this keyword has boolean value false, the instance validates successfully. If it has boolean value true, the instance validates successfully if all of its elements are unique. Omitting this keyword has the same behavior as a value of false.

reference

Kind: global function

Param Type
boolean boolean

minItems(min) ⇒ FluentSchema

An array instance is valid against "minItems" if its size is greater than, or equal to, the value of this keyword. Omitting this keyword has the same behavior as a value of 0.

reference

Kind: global function

Param Type
min number

maxItems(max) ⇒ FluentSchema

An array instance is valid against "minItems" if its size is greater than, or equal to, the value of this keyword. Omitting this keyword has the same behavior as a value of 0.

reference

Kind: global function

Param Type
max number

BaseSchema([options]) ⇒ BaseSchema

Represents a BaseSchema.

Kind: global function

Param Type Default Description
[options] Object Options
[options.schema] BaseSchema Default schema
[options.generateIds] boolean false generate the id automatically e.g. #properties.foo

id(id) ⇒ BaseSchema

It defines a URI for the schema, and the base URI that other URI references within the schema are resolved against.

reference

Kind: global function

Param Type Description
id string an #id

title(title) ⇒ BaseSchema

It can be used to decorate a user interface with information about the data produced by this user interface. A title will preferably be short.

reference

Kind: global function

Param Type
title string

description(description) ⇒ BaseSchema

It can be used to decorate a user interface with information about the data produced by this user interface. A description provides explanation about the purpose of the instance described by the schema.

reference

Kind: global function

Param Type
description string

examples(examples) ⇒ BaseSchema

The value of this keyword MUST be an array. There are no restrictions placed on the values within the array.

reference

Kind: global function

Param Type
examples string

ref(ref) ⇒ BaseSchema

The value must be a valid id e.g. #properties/foo

Kind: global function

Param Type
ref string

enum(values) ⇒ BaseSchema

The value of this keyword MUST be an array. This array SHOULD have at least one element. Elements in the array SHOULD be unique.

reference

Kind: global function

Param Type
values array

const(value) ⇒ BaseSchema

The value of this keyword MAY be of any type, including null.

reference

Kind: global function

Param
value

default(defaults) ⇒ BaseSchema

There are no restrictions placed on the value of this keyword.

reference

Kind: global function

Param
defaults

readOnly(isReadOnly) ⇒ BaseSchema

The value of readOnly can be left empty to indicate the property is readOnly. It takes an optional boolean which can be used to explicitly set readOnly true/false.

reference

Kind: global function

Param Type
isReadOnly boolean | undefined

writeOnly(isWriteOnly) ⇒ BaseSchema

The value of writeOnly can be left empty to indicate the property is writeOnly. It takes an optional boolean which can be used to explicitly set writeOnly true/false.

reference

Kind: global function

Param Type
isWriteOnly boolean | undefined

deprecated(isDeprecated) ⇒ BaseSchema

The value of deprecated can be left empty to indicate the property is deprecated. It takes an optional boolean which can be used to explicitly set deprecated true/false.

reference

Kind: global function

Param Type
isDeprecated Boolean

required() ⇒ FluentSchema

Required has to be chained to a property: Examples:

  • S.prop('prop').required()
  • S.prop('prop', S.number()).required()
  • S.required(['foo', 'bar'])

reference

Kind: global function

not(not) ⇒ BaseSchema

This keyword's value MUST be a valid JSON Schema. An instance is valid against this keyword if it fails to validate successfully against the schema defined by this keyword.

reference

Kind: global function

Param Type
not FluentSchema

anyOf(schemas) ⇒ BaseSchema

It MUST be a non-empty array. Each item of the array MUST be a valid JSON Schema.

reference

Kind: global function

Param Type
schemas array

allOf(schemas) ⇒ BaseSchema

It MUST be a non-empty array. Each item of the array MUST be a valid JSON Schema.

reference

Kind: global function

Param Type
schemas array

oneOf(schemas) ⇒ BaseSchema

It MUST be a non-empty array. Each item of the array MUST be a valid JSON Schema.

reference

Kind: global function

Param Type
schemas array

ifThen(ifClause, thenClause) ⇒ BaseSchema

This validation outcome of this keyword's subschema has no direct effect on the overall validation result. Rather, it controls which of the "then" or "else" keywords are evaluated. When "if" is present, and the instance successfully validates against its subschema, then validation succeeds against this keyword if the instance also successfully validates against this keyword's subschema.

Kind: global function

Param Type Description
ifClause BaseSchema reference
thenClause BaseSchema reference

ifThenElse(ifClause, thenClause, elseClause) ⇒ BaseSchema

When "if" is present, and the instance fails to validate against its subschema, then validation succeeds against this keyword if the instance successfully validates against this keyword's subschema.

Kind: global function

Param Type Description
ifClause BaseSchema reference
thenClause BaseSchema reference
elseClause BaseSchema reference

raw(fragment) ⇒ BaseSchema

Because the differences between JSON Schemas and Open API (Swagger) it can be handy to arbitrary modify the schema injecting a fragment

  • Examples:
  • S.number().raw({ nullable:true })
  • S.string().format('date').raw({ formatMaximum: '2020-01-01' })

Kind: global function

Param Type Description
fragment string an arbitrary JSON Schema to inject reference

valueOf([options]) ⇒ object

It returns all the schema values

Kind: global function

Param Type Default Description
[options] Object Options
[options.isRoot] boolean true Is a root level schema

BooleanSchema([options]) ⇒ StringSchema

Represents a BooleanSchema.

Kind: global function

Param Type Default Description
[options] Object Options
[options.schema] StringSchema Default schema
[options.generateIds] boolean false generate the id automatically e.g. #properties.foo

S([options]) ⇒ S

Represents a S.

Kind: global function

Param Type Default Description
[options] Object Options
[options.schema] S Default schema
[options.generateIds] boolean false generate the id automatically e.g. #properties.foo

string() ⇒ StringSchema

Set a property to type string

reference

Kind: global function

number() ⇒ NumberSchema

Set a property to type number

reference

Kind: global function

integer() ⇒ IntegerSchema

Set a property to type integer

reference

Kind: global function

boolean() ⇒ BooleanSchema

Set a property to type boolean

reference

Kind: global function

array() ⇒ ArraySchema

Set a property to type array

reference

Kind: global function

object() ⇒ ObjectSchema

Set a property to type object

reference

Kind: global function

null() ⇒ NullSchema

Set a property to type null

reference

Kind: global function

mixed(types) ⇒ MixedSchema

A mixed schema is the union of multiple types (e.g. ['string', 'integer']

Kind: global function

Param Type
types Array.<string>

raw(fragment) ⇒ BaseSchema

Because the differences between JSON Schemas and Open API (Swagger) it can be handy to arbitrary modify the schema injecting a fragment

  • Examples:
  • S.raw({ nullable:true, format: 'date', formatMaximum: '2020-01-01' })
  • S.string().format('date').raw({ formatMaximum: '2020-01-01' })

Kind: global function

Param Type Description
fragment string an arbitrary JSON Schema to inject

IntegerSchema([options]) ⇒ NumberSchema

Represents a NumberSchema.

Kind: global function

Param Type Default Description
[options] Object Options
[options.schema] NumberSchema Default schema
[options.generateIds] boolean false generate the id automatically e.g. #properties.foo

MixedSchema([options]) ⇒ StringSchema

Represents a MixedSchema.

Kind: global function

Param Type Default Description
[options] Object Options
[options.schema] MixedSchema Default schema
[options.generateIds] boolean false generate the id automatically e.g. #properties.foo

NullSchema([options]) ⇒ StringSchema

Represents a NullSchema.

Kind: global function

Param Type Default Description
[options] Object Options
[options.schema] StringSchema Default schema
[options.generateIds] boolean false generate the id automatically e.g. #properties.foo

null() ⇒ FluentSchema

Set a property to type null

reference

Kind: global function

NumberSchema([options]) ⇒ NumberSchema

Represents a NumberSchema.

Kind: global function

Param Type Default Description
[options] Object Options
[options.schema] NumberSchema Default schema
[options.generateIds] boolean false generate the id automatically e.g. #properties.foo

minimum(min) ⇒ FluentSchema

It represents an inclusive lower limit for a numeric instance.

reference

Kind: global function

Param Type
min number

exclusiveMinimum(min) ⇒ FluentSchema

It represents an exclusive lower limit for a numeric instance.

reference

Kind: global function

Param Type
min number

maximum(max) ⇒ FluentSchema

It represents an inclusive upper limit for a numeric instance.

reference

Kind: global function

Param Type
max number

exclusiveMaximum(max) ⇒ FluentSchema

It represents an exclusive upper limit for a numeric instance.

reference

Kind: global function

Param Type
max number

multipleOf(multiple) ⇒ FluentSchema

It's strictly greater than 0.

reference

Kind: global function

Param Type
multiple number

ObjectSchema([options]) ⇒ StringSchema

Represents a ObjectSchema.

Kind: global function

Param Type Default Description
[options] Object Options
[options.schema] StringSchema Default schema
[options.generateIds] boolean false generate the id automatically e.g. #properties.foo

id(id)

It defines a URI for the schema, and the base URI that other URI references within the schema are resolved against. Calling id on an ObjectSchema will alway set the id on the root of the object rather than in its "properties", which differs from other schema types.

reference

Kind: global function

Param Type Description
id string an #id

additionalProperties(value) ⇒ FluentSchema

This keyword determines how child instances validate for objects, and does not directly validate the immediate instance itself. Validation with "additionalProperties" applies only to the child values of instance names that do not match any names in "properties", and do not match any regular expression in "patternProperties". For all such properties, validation succeeds if the child instance validates against the "additionalProperties" schema. Omitting this keyword has the same behavior as an empty schema.

reference

Kind: global function

Param Type
value FluentSchema | boolean

maxProperties(max) ⇒ FluentSchema

An object instance is valid against "maxProperties" if its number of properties is less than, or equal to, the value of this keyword.

reference

Kind: global function

Param Type
max number

minProperties(min) ⇒ FluentSchema

An object instance is valid against "minProperties" if its number of properties is greater than, or equal to, the value of this keyword.

reference

Kind: global function

Param Type
min number

patternProperties(opts) ⇒ FluentSchema

Each property name of this object SHOULD be a valid regular expression, according to the ECMA 262 regular expression dialect. Each property value of this object MUST be a valid JSON Schema. This keyword determines how child instances validate for objects, and does not directly validate the immediate instance itself. Validation of the primitive instance type against this keyword always succeeds. Validation succeeds if, for each instance name that matches any regular expressions that appear as a property name in this keyword's value, the child instance for that name successfully validates against each schema that corresponds to a matching regular expression.

reference

Kind: global function

Param Type
opts object

dependencies(opts) ⇒ FluentSchema

This keyword specifies rules that are evaluated if the instance is an object and contains a certain property. This keyword's value MUST be an object. Each property specifies a dependency. Each dependency value MUST be an array or a valid JSON Schema. If the dependency value is a subschema, and the dependency key is a property in the instance, the entire instance must validate against the dependency value. If the dependency value is an array, each element in the array, if any, MUST be a string, and MUST be unique. If the dependency key is a property in the instance, each of the items in the dependency value must be a property that exists in the instance.

reference

Kind: global function

Param Type
opts object

dependentRequired(opts) ⇒ FluentSchema

The value of "properties" MUST be an object. Each dependency value MUST be an array. Each element in the array MUST be a string and MUST be unique. If the dependency key is a property in the instance, each of the items in the dependency value must be a property that exists in the instance.

reference

Kind: global function

Param Type
opts object

dependentSchemas(opts) ⇒ FluentSchema

The value of "properties" MUST be an object. The dependency value MUST be a valid JSON Schema. Each dependency key is a property in the instance and the entire instance must validate against the dependency value.

reference

Kind: global function

Param Type
opts object

propertyNames(value) ⇒ FluentSchema

If the instance is an object, this keyword validates if every property name in the instance validates against the provided schema. Note the property name that the schema is testing will always be a string.

reference

Kind: global function

Param Type
value FluentSchema

prop(name, props) ⇒ FluentSchema

The value of "properties" MUST be an object. Each value of this object MUST be a valid JSON Schema.

reference

Kind: global function

Param Type
name string
props FluentSchema

only(properties) ⇒ ObjectSchema

Returns an object schema with only a subset of keys provided. If called on an ObjectSchema with an $id, it will be removed and the return value will be considered a new schema.

Kind: global function

Param Description
properties a list of properties you want to keep

without(properties) ⇒ ObjectSchema

Returns an object schema without a subset of keys provided. If called on an ObjectSchema with an $id, it will be removed and the return value will be considered a new schema.

Kind: global function

Param Description
properties a list of properties you dont want to keep

definition(name, props) ⇒ FluentSchema

The "definitions" keywords provides a standardized location for schema authors to inline re-usable JSON Schemas into a more general schema. There are no restrictions placed on the values within the array.

reference

Kind: global function

Param Type
name string
props FluentSchema

RawSchema(schema) ⇒ FluentSchema

Represents a raw JSON Schema that will be parsed

Kind: global function

Param Type
schema Object

StringSchema([options]) ⇒ StringSchema

Represents a StringSchema.

Kind: global function

Param Type Default Description
[options] Object Options
[options.schema] StringSchema Default schema
[options.generateIds] boolean false generate the id automatically e.g. #properties.foo

minLength(min) ⇒ StringSchema

A string instance is valid against this keyword if its length is greater than, or equal to, the value of this keyword. The length of a string instance is defined as the number of its characters as defined by RFC 7159 [RFC7159].

reference

Kind: global function

Param Type
min number

maxLength(max) ⇒ StringSchema

A string instance is valid against this keyword if its length is less than, or equal to, the value of this keyword. The length of a string instance is defined as the number of its characters as defined by RFC 7159 [RFC7159].

reference

Kind: global function

Param Type
max number

format(format) ⇒ StringSchema

A string value can be RELATIVE_JSON_POINTER, JSON_POINTER, UUID, REGEX, IPV6, IPV4, HOSTNAME, EMAIL, URL, URI_TEMPLATE, URI_REFERENCE, URI, TIME, DATE,

reference

Kind: global function

Param Type
format string

pattern(pattern) ⇒ StringSchema

This string SHOULD be a valid regular expression, according to the ECMA 262 regular expression dialect. A string instance is considered valid if the regular expression matches the instance successfully.

reference

Kind: global function

Param Type
pattern string

contentEncoding(encoding) ⇒ StringSchema

If the instance value is a string, this property defines that the string SHOULD be interpreted as binary data and decoded using the encoding named by this property. RFC 2045, Sec 6.1 [RFC2045] lists the possible values for this property.

reference

Kind: global function

Param Type
encoding string

contentMediaType(mediaType) ⇒ StringSchema

The value of this property must be a media type, as defined by RFC 2046 [RFC2046]. This property defines the media type of instances which this schema defines.

reference

Kind: global function

Param Type
mediaType string