Creates a new VineString instance with optional configuration.
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
OptionaldataThe validation to use for validating the schema data type. Using a data type validator guards custom rules to only run when the data type validation passes.
Configuration options for this field including bail mode, nullability, and parsing
StaticrulesStatic collection of all available validation rules for strings
The subtype identifier for the literal schema field
Unique name identifier for union type resolution
Transforms your schema type into JSONSchema7
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 it.
Adds a validation rule to the schema's validation chain. Rules are executed in the order they are added.
The validation rule or rule builder to add
This schema instance for method chaining
Enable/disable bail mode for this field. In bail mode, field validations stop 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.
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.
Apply transform on the final validated value. The transform method may convert the value to any new datatype.
Compiles the literal schema type into a compiler node. This method transforms the schema definition into a format that the validation compiler can process.
Name of the property being compiled
Reference store for the compiler
Parser options including camelCase conversion
Compiled literal node with subtype information
Type checker function to determine if a value is a string. Required for "unionOfTypes" functionality.
The value to check
True if the value is a string
Validates the value to be a valid URL.
Optional URL validation options
This string schema instance for method chaining
Validates the value to be an active URL by making an HTTP request.
This string schema instance for method chaining
Validates the value to be a valid email address.
Optional email validation options
This string schema instance for method chaining
Validates the value to be a valid mobile phone number for specified locales.
This string schema instance for method chaining
Validates the value to be a valid VAT (Value Added Tax) number for specified countries.
This string schema instance for method chaining
Validates the value to be a valid IP address (IPv4 or IPv6).
Optionalversion: 4 | 6Optional IP version (4 for IPv4, 6 for IPv6). Omit to allow both.
This string schema instance for method chaining
Validates the value to be a valid hexadecimal color code.
This string schema instance for method chaining
Validates the value against a custom regular expression pattern.
The regular expression to match against
This string schema instance for method chaining
Validates the value to contain only alphabetic characters.
Optionaloptions: AlphaOptionsOptions to allow spaces, underscores, or dashes
This string schema instance for method chaining
Validates the value to contain only alphanumeric characters (letters and numbers).
Optionaloptions: AlphaOptionsOptions to allow spaces, underscores, or dashes
This string schema instance for method chaining
Enforce a minimum length on a string field.
The minimum required length
This string schema instance for method chaining
Enforce a maximum length on a string field.
The maximum allowed length
This string schema instance for method chaining
Enforce a fixed length on a string field.
The exact required length
This string schema instance for method chaining
Ensures the field is confirmed by having another field with "_confirmation" suffix (or a custom suffix). Useful for password confirmation fields.
Optionaloptions: { confirmationField?: string } | { as?: string }Optional configuration for the confirmation field name
OptionalconfirmationField?: stringThis string schema instance for method chaining
Trims leading and trailing whitespace from the string value.
This string schema instance for method chaining
Normalizes the email address by applying transformations like lowercasing and removing dots from Gmail addresses.
Optionaloptions: NormalizeEmailOptionsEmail normalization options
This string schema instance for method chaining
Converts the field value to UPPERCASE.
This string schema instance for method chaining
Converts the field value to lowercase.
This string schema instance for method chaining
Converts the field value to camelCase.
This string schema instance for method chaining
Escapes HTML entities in the string to prevent XSS attacks.
This string schema instance for method chaining
Normalizes a URL by applying standardization rules like removing trailing slashes, sorting query parameters, and stripping default ports.
This string schema instance for method chaining
Ensures the value starts with a specified substring.
The required starting substring
This string schema instance for method chaining
Ensures the value ends with a specified substring.
The required ending substring
This string schema instance for method chaining
Ensures the value matches the value of another field in the data.
The name of the field to compare with
This string schema instance for method chaining
Ensures the value does not match the value of another field in the data.
The name of the field to compare with
This string schema instance for method chaining
Ensures the field's value is one of the predefined choices.
Array of allowed values or function returning allowed values
This string schema instance for method chaining
Ensures the field's value is not in the predefined list.
Array of disallowed values or function returning disallowed values
This string schema instance for method chaining
Validates the value to be a valid credit card number for specified providers.
This string schema instance for method chaining
Validates the value to be a valid passport number for specified countries.
This string schema instance for method chaining
Validates the value to be a valid postal code for specified countries.
This string schema instance for method chaining
Validates the value to be a valid UUID (Universally Unique Identifier).
This string schema instance for method chaining
Validates the value to be a valid ULID (Universally Unique Lexicographically Sortable Identifier).
This string schema instance for method chaining
Validates the value contains only ASCII characters.
This string schema instance for method chaining
Validates the value to be a valid IBAN (International Bank Account Number).
This string schema instance for method chaining
Validates the value to be a valid JWT (JSON Web Token).
This string schema instance for method chaining
Validates the value to be a string containing latitude and longitude coordinates.
This string schema instance for method chaining
Clones the VineString schema type. The applied options and validations are copied to the new instance.
A cloned instance of this VineString schema
VineString represents a string value in the validation schema. It provides comprehensive string validation with built-in rules for common patterns like email, URL, UUID, and more.
Example