Protected isProtected preprocessorsA list of preprocessors associated with the Builder
Protected typeProtected validatorsA list of validators associated with the Builder
Adds a preprocessor to a preprocessors list
Adds a validator to validators list.
Remove all preprocessors for this schema.
Remove all validators for this schema.
Protected createProtected method used to create an new instance of the Builder
defined by the props object. Should be used to instanticate new
builders to keep builder's immutability.
arbitrary props object
Generates a serializable object describing the defined schema
If set to false, schema will be optional (null or undefined values
will be considered as valid).
Array of schemas participating in the union.
Array of preprocessor functions
String id of schema type, e.g. string', numberorobject`.
Array of validator functions
Adds a new schema option described by schema.
schema must be an instance of SchemaBuilder class ancestor.
schema to be added as an option.
Protected preRemoves first option from the union schema.
Removes option by its index. If index is out of bounds,
an error is thrown.
index of the option, starting from 0.
Removes all options and replaces them by single schema option.
Equivalent to union(schema) function, but could be useful in some cases.
schema to be added as a single option to the new schema.
Performs validion of the union schema over object.
Optional context: ValidationContextOptional ValidationContext settings.
Static createGenerated using TypeDoc
Union schema builder class. Allows to create schemas containing alternatives. E.g. string | number | Date. Use it when you want to define a schema for a value that can be of different types. The type of the value will be determined by the first schema that succeeds validation. Any schema type can be supplied as variant. Which means that you are not limited to primitive types and can construct complex types as well, e.g. object | array.
NOTE this class is exported only to give opportunity to extend it by inheriting. It is not recommended to create an instance of this class directly. Use () function instead.
Example
Example
Example
See
union