The underlying schema type to modify
Creates a new optional modifier wrapping the given schema.
The underlying schema type to modify
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.
Type marker for camelCase output type inference
List of 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.
Add meta to the field that can be retrieved once compiled. It is also merged with the json-schema.
Push a validation to the validations chain.
Creates a fresh instance of the underlying schema type and wraps it inside the optional modifier
Transforms your schema type into JSONSchema7
Compiles to compiler node
Modifies the schema type to allow undefined values in addition to the original schema type. This is useful for form fields that may not be present in the submitted data.
Example