Constructor that applies all registered instance properties to the new instance. This method iterates through the instanceMacros set and assigns each property to the instance, binding functions to the instance context.
Define a sub-object as a conditional union group. Groups allow creating conditional validations based on discriminator fields.
Define a union of multiple schema types. Union schemas attempt to validate against each schema until one succeeds.
Define a string value schema with comprehensive validation rules.
A VineString schema instance
Define a boolean value schema with optional strict mode.
Optionaloptions: { strict: boolean }Configuration options for boolean validation
A VineBoolean schema instance
Validate a checkbox or acceptance field to be checked/accepted.
A VineAccepted schema instance
Define a number value schema with optional strict mode.
Optionaloptions: { strict: boolean }Configuration options for number validation
A VineNumber schema instance
Define a datetime value schema with optional parsing options.
Optionaloptions: DateFieldOptionsConfiguration options for date validation
A VineDate schema instance
Define a schema type that validates input matches a specific literal value. Useful for validating exact strings, numbers, or boolean values.
The literal value type to validate against
The exact value that input must match
A VineLiteral schema instance
Define an optional value that can be undefined. Chain the "nullable" method to also allow null values in the output.
A VineOptional schema instance
Define an object schema with known properties and their validation schemas. You may call "allowUnknownProperties" to merge unknown properties into the output.
Record of property names to their schema types
Object defining the schema for each property
A VineObject schema instance
Define an array schema that validates each element against a given schema. All elements in the array must conform to the same schema type.
The schema type for validating array elements
The schema to validate each array element against
A VineArray schema instance
Define a tuple schema with fixed length where each element can have its own validation schema.
Array of schema types for each tuple position
Array of schemas for each tuple element
A VineTuple schema instance
Define a record (dictionary) schema with unknown string keys and values that conform to a specific schema type.
The schema type for validating record values
The schema to validate each record value against
A VineRecord schema instance
Define an enum schema that validates input against a predefined set of choices. Supports both array-based enums and TypeScript native enums.
The enum values type (array or enum-like object)
VineEnum or VineNativeEnum schema instance
Define an enum schema that validates input against a predefined set of choices. Supports both array-based enums and TypeScript native enums.
The enum values type (array or enum-like object)
Array of allowed values, function returning values, or TypeScript enum
VineEnum or VineNativeEnum schema instance
Define a schema that accepts any value without validation. Use sparingly as it bypasses type safety and validation.
A VineAny schema instance
Define a union of unique schema types with intelligent type discrimination. Unlike regular unions, this validates against the most specific matching schema using runtime type checking.
The schema types in the union
Array of distinct schema types for the union
A VineUnionOfTypes schema instance
Define a schema that validates native File instances. Useful for file upload validation in web applications.
A VineNativeFile schema instance
SchemaBuilder exposes methods to construct Vine validation schemas. It provides a fluent API for creating all supported schema types and can be extended with custom methods using macros.
Example