Record of property names to their schema types
The expected input type for this object
The output type after validation and transformation
The output type with camelCase property names
Creates a new VineObject instance with property schemas and optional configuration.
Record of property names to their schema types
The expected input type for this object
The output type after validation and transformation
The output type with camelCase property names
Record of property names to their validation schemas
Optionaloptions: FieldOptionsField options like bail mode and nullability
Optionalvalidations: Validation<any>[]Initial set of validations to apply
Define the input type of the schema for TypeScript inference
The output value type of the field after validation. The property points to a type only and not the real value.
Type marker for camelCase output type inference
Unique name identifier for union type resolution
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
This schema instance for method chaining
Push a validation to the validations chain.
Validation rule or rule builder to add
This schema instance for method chaining
Enable/disable the bail mode. In bail mode, the field validations are stopped after the first error.
Whether to enable bail mode
This schema instance for method chaining
Mark the field under validation as optional. An optional field allows both null and undefined values.
A new OptionalModifier wrapping this schema
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.
A new NullableModifier wrapping this schema
Add meta to the field that can be retrieved once compiled. It is also merged with the json-schema.
Type checker function to determine if a value is an object. Required for "unionOfTypes" functionality.
The value to check
True if the value is a non-null object and not an array
Returns a cloned copy of all object properties with their validation schemas. Note: Object groups are not included to keep implementations simple.
Cloned properties record
Returns a cloned subset of object properties containing only the specified keys.
Picked properties record
Returns a cloned copy of object properties excluding the specified keys.
Omitted properties record
Allows unknown properties to pass through validation and be included in the output. By default, objects with properties not defined in the schema will fail validation.
This object schema with unknown properties allowed
Merges conditional property groups into the object schema. Groups allow adding properties dynamically based on runtime conditions.
The conditional group to merge
This object schema with the group merged
Clones the VineObject schema including all properties, validations, groups, and options.
A cloned instance of this VineObject schema
Converts object property names to camelCase in the validation output. Useful when accepting snake_case input but wanting camelCase output.
A VineCamelCaseObject wrapper for this schema
Converts the object schema to JSON Schema format.
JSON Schema representation of this object
Creates a new object schema with all properties (or specified properties) marked as optional. This is useful for update/PATCH operations where not all fields are required.
A new VineObject schema with optional properties
Compiles the schema type to a compiler node for validation.
Name of the property being compiled
Reference store for the compiler
Parser options
Compiled object node for validation
VineObject represents an object value in the validation schema. It validates objects with predefined properties, supports conditional groups, and provides control over unknown properties.
Example