Returns a new schema that requires that either this schema is satisfied or that the value is null
.
If true
, extra keys won't be removed. This effects the directly described value but not sub-values.
Readonly
cloneDeeply clones a value
Deeply clones a value
Optional
descriptionA description, which can be used by code generation tools to generate documentation
Deserialize (and validate) a value
Deserialize (and validate) a value
An estimate of the time complexity for validating this element, which should be on the same order of the number of items to be validated
Optional
exampleAn example, which can be used by code generation tools to generate documentation
If true
, this schema or any sub-elements have the potential to represent an object value that might need unknown-key removal
A marker that can be used for testing if this is a YaSchema schema
Readonly
mapReturns a new schema that requires that this schema is satisfied but that the specified schema cannot be satisfied.
Returns a new schema that requires that either this schema is satisfied or that the value is undefined
.
Parse and deserialize a value from a JSON string
Parse and deserialize a value from a JSON string
The preferred validation mode for this schema.
The lesser level of the preferred validation mode, which will be applied recursively depending on the depth
parameter / unless
further re-specified, and the specified validation mode, will be used, where the order is none < soft < hard
.
Special Values:
"initial"
- use the initially specified validation mode for the current operation (ex. the validation
field of the options
parameter to deserialize
)."inherit"
- use the closet applicable mode from an ancestor schema level.Readonly
schemaSerialize (and validate) a value
Serialize (and validate) a value
Readonly
setSets (replaces) the description metadata for this schema and returns the same schema
Sets (replaces) the example metadata for this schema and returns the same schema
Sets (replaces) the preferred validation mode for this schema and returns the same schema.
The lesser level of the preferred validation mode, which will be applied recursively depending on the depth
parameter / unless
further re-specified, and the specified validation mode, will be used, where the order is none < soft < hard
.
The preferred validation mode for this schema Special Values:
"initial"
- use the initially specified validation mode for the current operation (ex. the validation
field of the options
parameter to deserialize
)."inherit"
- use the closet applicable mode from an ancestor schema level.Serialize (and validate) and stringify a value
Serialize (and validate) and stringify a value
Makes a string representation of this schema, mostly for debugging
If true
, this schema or any sub-elements have a custom serializer-deserializer
Validate a value. This throws if the schema requires async validation.
Validate a value
The actual value of this field is always undefined
, but this should be used for determining the value type represented by this
schema, ex. typeof someSchema.valueType
Requires an object, where each key has it's own schema. Unlike with
ObjectSchema
, the keys of values that may beundefined
are not automatically treated as optional. You may explicitly provide a type parameter when using…_noAutoOptional
methods, and that may include optional keys.