The output type when the value is defined
Creates a new VineOptional instance.
The output type when the value is defined
Optionaloptions: Partial<FieldOptions>Field options like bail mode and nullability
Optionalvalidations: Validation<any>[]Initial set of validations to apply
The input type of the schema (null or undefined)
The output type of the schema when value is defined
The camelCase output type of the schema
The subtype identifier for the literal schema field
Unique name identifier for union type resolution
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
Type checker function to determine if a value is optional (null or undefined). Required for "unionOfTypes" functionality.
The value to check
Define a method to parse the input value. The method is invoked before any validation and hence you must perform type-checking to know the value you are working with.
Parser function to transform the input value
Push a validation to the validations chain.
Validation rule or rule builder to add
Enable/disable the bail mode. In bail mode, the field validations are stopped after the first error.
True to enable bail mode, false to disable
Clones the VineOptional schema type. The applied options and validations are copied to the new instance.
A cloned instance of this VineOptional schema
Mark the field under validation to be nullable. The null value will be written to the output as well. When combined with optional, both null and undefined values are allowed.
Transforms into JSON Schema format.
Compiles the schema type to a compiler node.
The name of the property being validated
Reference store for tracking validators and parsers
Parser options including camelCase transformation
VineOptional represents an optional value inside a union or schema. It allows both null and undefined values to pass validation.
This type is typically used with unions to make certain branches optional, or to explicitly mark a field as allowing undefined/null values.
Example
Example