The underlying literal schema type to make optional
Creates a new optional modifier wrapping the given schema.
The underlying literal schema type to make optional
The schema to make optional
Optionalvalidations: Validation<any>[]Optional list of validations to apply
Define the input type of the schema, including undefined and null
The output value of the field with undefined support. The property points to a type only and not the real value.
Camelcase output type with undefined support
List of additional validations to apply to non-undefined values
Marks the field as required when a condition is met. Can be used with a callback or with comparison operators to compare another field's value.
Field name to compare or callback function
Comparison operator (=, !=, in, notIn, >, <, >=, <=)
Expected value to compare against
Marks the field as required when a condition is met. Can be used with a callback or with comparison operators to compare another field's value.
Marks the field as required when all specified fields exist (are not undefined or null).
Field name or array of field names to check for existence
Marks the field as required when any one of the specified fields exists (is not undefined or null).
Array of field names to check for existence
Marks the field as required when all specified fields are missing (undefined or null).
Field name or array of field names to check for absence
Marks the field as required when any one of the specified fields is missing (undefined or null).
Array of field names to check for absence
Mark the field under validation to be null. The null value will be written to the output as well.
If optional and nullable are used together, then both undefined
and null values will be allowed.
Apply transform on the final validated value. The transform method may convert the value to any new datatype.
Push a validation to the validations chain.
Creates a fresh instance of the underlying schema type and wraps it inside the optional modifier
Add meta to the field that can be retrieved once compiled. It is also merged with the json-schema.
Transforms your schema type into JSONSchema7
Compiles to compiler node
Modifies a literal schema type to allow undefined values in addition to the original type. This modifier is used for form fields that may not be present in submitted data.
Example