The schema type for validating all record values
Creates a new VineRecord instance with value schema and optional configuration.
The schema type for validating all record values
The schema to validate each record value
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
StaticrulesStatic collection of all available validation rules for records
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
Enforce a minimum number of properties on the record.
The minimum required number of key-value pairs
This record schema instance for method chaining
Enforce a maximum number of properties on the record.
The maximum allowed number of key-value pairs
This record schema instance for method chaining
Enforce an exact number of properties on the record.
The exact required number of key-value pairs
This record schema instance for method chaining
Register a custom callback to validate the record's keys. Useful for enforcing key naming patterns or checking key existence.
Arguments to pass to the validateKeys rule
This record schema instance for method chaining
Clones the VineRecord schema including the value schema, options, and validations.
A cloned instance of this VineRecord schema
Converts the record schema to JSON Schema format.
JSON Schema representation of this record
Compiles the record schema to a compiler node for validation.
Name of the property being compiled
Reference store for the compiler
Parser options
Compiled record node for validation
VineRecord represents an object with dynamic keys where all values share the same schema. Unlike VineObject which has predefined properties, records allow any string key but enforce consistent value types across all keys.
Example
Example