Global

Members

bool

Get a new BooleanSchema object.

double

Get a new NumberSchema object.

int

Get a new IntegerSchema object.

map

Get a new MapSchema object.

media

Get a new MediaSchema object.

null

Gets the schema for null (a constant).

str

Get a new StringSchema object.

Methods

arr(schema)

Parameters:
Name Type Description
schema BaseSchema See ArraySchema#constructor
Returns:
- A new ArraySchema object.

const()

Get a new const schema.

enum()

Get a new num.

formatParagraph(p, options) → {String}

Formats a paragraph into a string.
Parameters:
Name Type Description
p String | Array.<String> the string or array of strings to process
options formatParagraphOptions how to format the string
Returns:
String - formatted string

lock(schemas)

Lock all schemas in a dictionary (in-place).
Parameters:
Name Type Description
schemas Object.<Schema> a map of schema values
Returns:
- the input map of schema values

nullable()

Returns a schema which is either null or the specified schema.

obj(object)

Parameters:
Name Type Description
object Object See ObjectSchema#constructor
Returns:
- A new ObjectSchema object.

optional(schemas)

Sets all schemas as optional (in-place).
Parameters:
Name Type Description
schemas Object.<Schema> a map of schema values
Returns:
- the input map of schema values

polymorphicObj(object)

Parameters:
Name Type Description
object Object See ObjectSchema#constructor
Returns:
- A new ObjectSchema object.

ref()

Get a new RefSchema object.

union()

Gets a schema which is a union of two or more schemas.

Type Definitions

formatParagraphOptions

Options to format a paragraph
Properties:
Name Type Description
replaceNewlines String | false if not false, then newlines will be replaced with this character
trim boolean whether to trim whitespace from the start/end (for arrays, each element will be trimmed too)