import { a as BOOLEAN_NEGATIVES, c as __exportAll, i as SimpleMessagesProvider, n as main_exports, o as BOOLEAN_POSITIVES, r as ValidationError, s as helpers, t as SimpleErrorReporter } from "./simple_error_reporter-cwDwkClZ.js";
import { fields, globalTransforms, messages } from "./src/defaults.js";
import dayjs from "dayjs";
import Macroable from "@poppinss/macroable";
import camelcase from "camelcase";
import normalizeUrl from "normalize-url";
import escapeValue from "validator/lib/escape.js";
import normalizeEmailValue from "validator/lib/normalizeEmail.js";
import { Compiler, refsBuilder } from "@vinejs/compiler";
//#region src/vine/create_rule.ts
/**
* Creates a reusable validation rule from a validator function.
* The returned function can be applied to any schema type using the `schema.use()` method.
* Automatically detects async functions and provides proper metadata.
*
* @template Options - The type of options the validator accepts
* @param validator - The validation function to convert into a rule
* @param metaData - Optional metadata about the validation rule
* @param metaData.name - Custom name for the rule (defaults to function name)
* @param metaData.implicit - Whether the rule runs on null/undefined values
* @param metaData.isAsync - Whether the validator is async (auto-detected if not specified)
* @param metaData.toJSONSchema - Optional function to modify the JSON Schema representation
*
* @example
* // Simple validation rule
* const isEven = createRule<{ strict?: boolean }>((value, options, field) => {
*   const num = Number(value)
*   if (num % 2 !== 0) {
*     throw new Error('Value must be even')
*   }
*   return value
* })
*
* // Usage with schema
* vine.number().use(isEven({ strict: true }))
*
* @example
* // Async validation rule
* const checkUnique = createRule<{ table: string }>(async (value, { table }, field) => {
*   const exists = await database.exists(table, value)
*   if (exists) {
*     throw new Error('Value must be unique')
*   }
*   return value
* }, { name: 'unique', isAsync: true })
*
* // Usage
* vine.string().use(checkUnique({ table: 'users' }))
*/
function createRule(validator, metaData) {
	const rule = {
		validator,
		name: metaData?.name ?? validator.name,
		isAsync: metaData?.isAsync || validator.constructor.name === "AsyncFunction",
		implicit: metaData?.implicit ?? false,
		toJSONSchema: metaData?.toJSONSchema
	};
	return function(...options) {
		return {
			rule,
			options: options[0]
		};
	};
}
//#endregion
//#region src/symbols.ts
var symbols_exports = /* @__PURE__ */ __exportAll({
	COTYPE: () => COTYPE,
	IS_OF_TYPE: () => IS_OF_TYPE,
	ITYPE: () => ITYPE,
	OTYPE: () => OTYPE,
	PARSE: () => PARSE,
	SUBTYPE: () => SUBTYPE,
	UNIQUE_NAME: () => UNIQUE_NAME,
	VALIDATION: () => VALIDATION
});
/**
* The symbol to define a unique name for the schema type.
* Used internally to identify schema types for union type validation.
*
* @example
* class MySchema {
*   [UNIQUE_NAME] = 'mySchema'
* }
*/
const UNIQUE_NAME = Symbol.for("schema_name");
/**
* The symbol to check if a value is of the given schema type.
* Used by union schemas to determine which schema variant matches a value.
*
* @example
* class StringSchema {
*   [IS_OF_TYPE](value: unknown) {
*     return typeof value === 'string'
*   }
* }
*/
const IS_OF_TYPE = Symbol.for("is_of_type");
/**
* The symbol for the compile method that transforms a schema into compiler nodes.
* This method is called during schema compilation to generate validation functions.
*
* @example
* class MySchema {
*   [PARSE](propertyName: string, refs: RefsStore, options: ParserOptions) {
*     return { type: 'literal', subtype: 'string' }
*   }
* }
*/
const PARSE = Symbol.for("parse");
/**
* The symbol for the opaque input type used in TypeScript type inference.
* Represents the expected input type before validation and transformation.
*
* @example
* class StringSchema {
*   [ITYPE]: string | undefined
* }
*/
const ITYPE = Symbol.for("opaque_input_type");
/**
* The symbol for the opaque output type used in TypeScript type inference.
* Represents the validated and transformed output type.
*
* @example
* class StringSchema {
*   [OTYPE]: string
* }
*/
const OTYPE = Symbol.for("opaque_type");
/**
* The symbol for the camelcase opaque output type used in TypeScript type inference.
* Represents the output type when field names are converted to camelCase.
*
* @example
* class ObjectSchema {
*   [COTYPE]: { userName: string } // from user_name
* }
*/
const COTYPE = Symbol.for("camelcase_opaque_type");
/**
* The symbol to generate a validation rule from rule builder.
* Used by rule builders to convert themselves into validation rules.
*
* @example
* class MinLengthRule {
*   [VALIDATION]() {
*     return { rule: minLengthRule, options: this.length }
*   }
* }
*/
const VALIDATION = Symbol.for("to_validation");
/**
* The symbol for the subtype of a literal field.
* Used to identify the specific subtype of literal schema types (string, number, etc.).
*
* @example
* class StringSchema {
*   [SUBTYPE] = 'string'
* }
*/
const SUBTYPE = Symbol.for("subtype");
//#endregion
//#region src/schema/base/rules.ts
/**
* Validation rule that makes a field required when a specified condition is met.
* This rule is implicit, meaning it runs even when the field value is undefined.
*
* @param checker - Callback function that returns true if the field should be required
*
* @example
* vine.string().optional().use(requiredWhen((field) => {
*   return field.data.role === 'admin'
* }))
*/
const requiredWhen = createRule(function requiredWhen(_, checker, field) {
	const shouldBeRequired = checker(field);
	if (!field.isDefined && shouldBeRequired) field.report(messages.required, "required", field);
}, { implicit: true });
//#endregion
//#region src/schema/base/conditional_rules.ts
/**
* Abstract base class providing conditional validation methods for making fields
* required based on runtime conditions. This class is extended by schema types
* that support conditional validation.
*
* @example
* vine.string().optional().requiredWhen('role', '=', 'admin')
*/
var ConditionalValidations = class {
	requiredWhen(otherField, operator, expectedValue) {
		/**
		* The equality check if self implemented
		*/
		if (typeof otherField === "function") return this.use(requiredWhen(otherField));
		/**
		* Creating the checker function based upon the
		* operator used for the comparison
		*/
		let checker;
		switch (operator) {
			case "=":
				checker = (value) => value === expectedValue;
				break;
			case "!=":
				checker = (value) => value !== expectedValue;
				break;
			case "in":
				checker = (value) => expectedValue.includes(value);
				break;
			case "notIn":
				checker = (value) => !expectedValue.includes(value);
				break;
			case ">":
				checker = (value) => value > expectedValue;
				break;
			case "<":
				checker = (value) => value < expectedValue;
				break;
			case ">=":
				checker = (value) => value >= expectedValue;
				break;
			case "<=": checker = (value) => value <= expectedValue;
		}
		/**
		* Registering rule with custom implementation
		*/
		return this.use(requiredWhen((field) => {
			const otherFieldValue = helpers.getNestedValue(otherField, field);
			return checker(otherFieldValue);
		}));
	}
	/**
	* Marks the field as required when all specified fields exist (are not undefined or null).
	*
	* @param fields - Field name or array of field names to check for existence
	*
	* @example
	* vine.string().optional().requiredIfExists('email')
	*
	* @example
	* vine.string().optional().requiredIfExists(['firstName', 'lastName'])
	*/
	requiredIfExists(fields) {
		const fieldsToExist = Array.isArray(fields) ? fields : [fields];
		return this.use(requiredWhen((field) => {
			return fieldsToExist.every((otherField) => {
				return helpers.exists(helpers.getNestedValue(otherField, field));
			});
		}));
	}
	/**
	* Marks the field as required when any one of the specified fields exists (is not undefined or null).
	*
	* @param fields - Array of field names to check for existence
	*
	* @example
	* vine.string().optional().requiredIfAnyExists(['email', 'phone'])
	*/
	requiredIfAnyExists(fields) {
		return this.use(requiredWhen((field) => {
			return fields.some((otherField) => helpers.exists(helpers.getNestedValue(otherField, field)));
		}));
	}
	/**
	* Marks the field as required when all specified fields are missing (undefined or null).
	*
	* @param fields - Field name or array of field names to check for absence
	*
	* @example
	* vine.string().optional().requiredIfMissing('addressId')
	*
	* @example
	* vine.string().optional().requiredIfMissing(['street', 'city'])
	*/
	requiredIfMissing(fields) {
		const fieldsToExist = Array.isArray(fields) ? fields : [fields];
		return this.use(requiredWhen((field) => {
			return fieldsToExist.every((otherField) => helpers.isMissing(helpers.getNestedValue(otherField, field)));
		}));
	}
	/**
	* Marks the field as required when any one of the specified fields is missing (undefined or null).
	*
	* @param fields - Array of field names to check for absence
	*
	* @example
	* vine.string().optional().requiredIfAnyMissing(['street', 'city', 'zipCode'])
	*/
	requiredIfAnyMissing(fields) {
		return this.use(requiredWhen((field) => {
			return fields.some((otherField) => helpers.isMissing(helpers.getNestedValue(otherField, field)));
		}));
	}
};
//#endregion
//#region src/schema/base/literal.ts
/**
* Modifies the schema type to allow null values
*/
var NullableModifier$1 = class NullableModifier$1 {
	allowNull = true;
	get isOptional() {
		return this.#parent.isOptional;
	}
	#parent;
	constructor(parent) {
		this.#parent = parent;
	}
	/**
	* Creates a fresh instance of the underlying schema type
	* and wraps it inside the nullable modifier
	*/
	clone() {
		return new NullableModifier$1(this.#parent.clone());
	}
	/**
	* Mark the field under validation as optional.
	* When combined with nullable, allows both null and undefined values.
	*
	* @returns A new OptionalModifier wrapping this nullable schema
	*/
	optional() {
		return new OptionalModifier$1(this);
	}
	/**
	* Apply a transformation to the final validated value.
	* The transformer receives the validated value and can convert it to any new datatype.
	*
	* @template TransformedOutput - The type of the transformed output
	* @param transformer - Function to transform the validated value
	* @returns A new TransformModifier wrapping this schema
	*
	* @example
	* vine.string().nullable().transform((value) => {
	*   return value ? value.toUpperCase() : null
	* })
	*/
	transform(transformer) {
		return new TransformModifier(transformer, this);
	}
	/**
	* Add meta to the field that can be retrieved once compiled.
	* It is also merged with the json-schema.
	*/
	meta(meta) {
		return new MetaModifier$1(this, meta);
	}
	toJSONSchema() {
		const schema = this.#parent.toJSONSchema?.() ?? {};
		if (schema.anyOf) {
			schema.anyOf.push({ type: "null" });
			return schema;
		}
		if (schema.enum) return { anyOf: [schema, { type: "null" }] };
		if (schema.type === void 0) {
			schema.type = "null";
			return schema;
		}
		if (typeof schema.type === "string") {
			schema.type = [schema.type, "null"];
			return schema;
		}
		if (Array.isArray(schema.type)) {
			schema.type.push("null");
			return schema;
		}
		return schema;
	}
	/**
	* Compiles to compiler node
	*/
	[PARSE](propertyName, refs, options) {
		const output = this.#parent[PARSE](propertyName, refs, options);
		output.allowNull = true;
		return output;
	}
};
/**
* Adds meta data to the schema type.
*/
var MetaModifier$1 = class MetaModifier$1 {
	get isOptional() {
		return this.#parent.isOptional;
	}
	get allowNull() {
		return this.#parent.allowNull;
	}
	#parent;
	#meta;
	constructor(parent, meta) {
		this.#parent = parent;
		this.#meta = meta;
	}
	/**
	* Mark the field under validation as optional. An optional
	* field allows both null and undefined values.
	*/
	optional() {
		return new OptionalModifier$1(this);
	}
	/**
	* Apply a transformation to the final validated value.
	* The transformer receives the validated value and can convert it to any new datatype.
	*
	* @template TransformedOutput - The type of the transformed output
	* @param transformer - Function to transform the validated value
	* @returns A new TransformModifier wrapping this schema
	*
	* @example
	* vine.string().nullable().transform((value) => {
	*   return value ? value.toUpperCase() : null
	* })
	*/
	transform(transformer) {
		return new TransformModifier(transformer, this);
	}
	/**
	* 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.
	*/
	nullable() {
		return new NullableModifier$1(this);
	}
	/**
	* Creates a fresh instance of the underlying schema type
	* and wraps it inside the meta modifier
	*/
	clone() {
		return new MetaModifier$1(this.#parent.clone(), this.#meta);
	}
	toJSONSchema() {
		return {
			...this.#parent.toJSONSchema?.() ?? {},
			...this.#meta
		};
	}
	/**
	* Compiles to compiler node
	*/
	[PARSE](propertyName, refs, options) {
		const output = this.#parent[PARSE](propertyName, refs, options);
		output.allowNull = true;
		return output;
	}
};
/**
* Modifies a literal schema type to allow undefined values in addition to the original type.
* This modifier is used for form fields that may not be present in submitted data.
*
* @template Schema - The underlying literal schema type to make optional
*
* @example
* const schema = vine.string().optional()
* // Accepts: "hello", undefined
* // Rejects: null (unless also nullable), 123
*/
var OptionalModifier$1 = class OptionalModifier$1 extends ConditionalValidations {
	isOptional = true;
	get allowNull() {
		return this.#parent.allowNull;
	}
	/** Reference to the parent schema being modified */
	#parent;
	/**
	* List of additional validations to apply to non-undefined values
	*/
	validations;
	/**
	* Creates a new optional modifier wrapping the given schema.
	*
	* @param parent - The schema to make optional
	* @param validations - Optional list of validations to apply
	*/
	constructor(parent, validations) {
		super();
		this.#parent = parent;
		this.validations = validations || [];
	}
	/**
	* Shallow clones the validations. Since there are no APIs to mutate
	* the validation options, we can safely copy them by reference.
	*
	* @returns Cloned array of validations
	*/
	cloneValidations() {
		return this.validations.map((validation) => {
			return {
				options: validation.options,
				rule: validation.rule
			};
		});
	}
	/**
	* Compiles validations into a format suitable for the validator compiler.
	*
	* @param refs - Reference store for tracking validation functions
	* @returns Compiled validation definitions
	*/
	compileValidations(refs) {
		return this.validations.map((validation) => {
			return {
				ruleFnId: refs.track({
					validator: validation.rule.validator,
					options: validation.options
				}),
				name: validation.rule.name,
				implicit: validation.rule.implicit,
				isAsync: validation.rule.isAsync
			};
		});
	}
	/**
	* 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.
	*/
	nullable() {
		return new NullableModifier$1(this);
	}
	/**
	* Apply transform on the final validated value. The transform method may
	* convert the value to any new datatype.
	*/
	transform(transformer) {
		return new TransformModifier(transformer, this);
	}
	/**
	* Push a validation to the validations chain.
	*/
	use(validation) {
		this.validations.push(VALIDATION in validation ? validation[VALIDATION]() : validation);
		return this;
	}
	/**
	* Creates a fresh instance of the underlying schema type
	* and wraps it inside the optional modifier
	*/
	clone() {
		return new OptionalModifier$1(this.#parent.clone(), this.cloneValidations());
	}
	/**
	* Add meta to the field that can be retrieved once compiled.
	* It is also merged with the json-schema.
	*/
	meta(meta) {
		return new MetaModifier$1(this, meta);
	}
	toJSONSchema() {
		return { ...this.#parent.toJSONSchema() };
	}
	/**
	* Compiles to compiler node
	*/
	[PARSE](propertyName, refs, options) {
		const output = this.#parent[PARSE](propertyName, refs, options);
		output.isOptional = true;
		output.validations = output.validations.concat(this.compileValidations(refs));
		return output;
	}
};
/**
* Modifies a literal schema type to apply custom transformations to validated values.
* This modifier allows converting validated values to any new datatype after validation.
*
* @template Schema - The underlying literal schema type to transform
* @template Output - The type of the transformed output
*
* @example
* const schema = vine.string().transform((value) => value.toUpperCase())
* // Input: "hello" -> Output: "HELLO"
*/
var TransformModifier = class TransformModifier {
	get isOptional() {
		return this.#parent.isOptional;
	}
	get allowNull() {
		return this.#parent.allowNull;
	}
	/** Reference to the parent schema being transformed */
	#parent;
	/** The transformation function to apply */
	#transform;
	/**
	* Creates a new transform modifier wrapping the given schema.
	*
	* @param transform - The transformation function to apply to validated values
	* @param parent - The schema to apply transformations to
	*/
	constructor(transform, parent) {
		this.#transform = transform;
		this.#parent = parent;
	}
	/**
	* Creates a fresh instance of the underlying schema type
	* and wraps it inside the transform modifier.
	*
	* @returns A cloned instance of this transform modifier
	*/
	clone() {
		return new TransformModifier(this.#transform, this.#parent.clone());
	}
	/**
	* Mark the field under validation as optional. An optional
	* field allows both null and undefined values.
	*/
	optional() {
		return new OptionalModifier$1(this);
	}
	/**
	* 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.
	*/
	nullable() {
		return new NullableModifier$1(this);
	}
	/**
	* Add meta to the field that can be retrieved once compiled.
	* It is also merged with the json-schema.
	*/
	meta(meta) {
		return new MetaModifier$1(this, meta);
	}
	toJSONSchema() {
		return this.#parent.toJSONSchema();
	}
	/**
	* Compiles to compiler node
	*/
	[PARSE](propertyName, refs, options) {
		const output = this.#parent[PARSE](propertyName, refs, options);
		output.transformFnId = refs.trackTransformer(this.#transform);
		return output;
	}
};
/**
* The base type for creating a custom literal type. Literal types
* are schema types that have no children elements, such as strings,
* numbers, booleans, and dates.
*
* @template Input - The expected input type for this schema
* @template Output - The output type after validation and transformation
* @template CamelCaseOutput - The output type with camelCase field names
*
* @example
* class CustomLiteralType extends BaseLiteralType<string, string, string> {
*   [SUBTYPE] = 'custom'
*   clone() { return new CustomLiteralType() }
* }
*/
var BaseLiteralType = class extends Macroable {
	/**
	* The 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.
	*
	* @example
	* class StringSchema extends BaseLiteralType {
	*   dataTypeValidator = stringDataTypeRule
	* }
	*/
	dataTypeValidator;
	/**
	* Configuration options for this field including bail mode, nullability, and parsing
	*/
	options;
	/**
	* Array of validation rules to apply to the field value
	*/
	validations;
	/**
	* Creates a new BaseLiteralType instance with optional configuration.
	*
	* @param options - Field options like bail mode and nullability
	* @param validations - Initial set of validations to apply
	*/
	constructor(options, validations) {
		super();
		this.options = {
			bail: true,
			allowNull: false,
			isOptional: false,
			...options
		};
		this.validations = validations || [];
	}
	/**
	* Shallow clones the validations. Since there are no APIs to mutate
	* the validation options, we can safely copy them by reference.
	*
	* @returns Cloned array of validations
	*/
	cloneValidations() {
		return this.validations.map((validation) => {
			return {
				options: validation.options,
				rule: validation.rule
			};
		});
	}
	/**
	* Shallow clones the field options.
	*
	* @returns Cloned field options object
	*/
	cloneOptions() {
		return { ...this.options };
	}
	/**
	* Compiles a single validation rule into a compiler validation node.
	*
	* @param validation - The validation rule to compile
	* @param refs - Reference store for tracking validation functions
	* @returns Compiled validation node
	*/
	compileValidation(validation, refs) {
		return {
			ruleFnId: refs.track({
				validator: validation.rule.validator,
				options: validation.options
			}),
			name: validation.rule.name,
			implicit: validation.rule.implicit,
			isAsync: validation.rule.isAsync
		};
	}
	/**
	* Compiles all validation rules into compiler validation nodes.
	*
	* @param refs - Reference store for tracking validation functions
	* @returns Array of compiled validation nodes
	*/
	compileValidations(refs) {
		return this.validations.map((validation) => this.compileValidation(validation, refs));
	}
	toJSONSchema() {
		const schema = {};
		if (this.dataTypeValidator?.rule.toJSONSchema) this.dataTypeValidator.rule.toJSONSchema(schema, this.dataTypeValidator.options);
		for (const validation of this.validations) {
			if (!validation.rule.toJSONSchema) continue;
			validation.rule.toJSONSchema(schema, validation.options);
		}
		return schema;
	}
	/**
	* 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.
	*/
	parse(callback) {
		this.options.parse = callback;
		return this;
	}
	/**
	* Adds a validation rule to the schema's validation chain.
	* Rules are executed in the order they are added.
	*
	* @param validation - The validation rule or rule builder to add
	* @returns This schema instance for method chaining
	*
	* @example
	* vine.string().use(minLength({ length: 3 }))
	* vine.number().use(customRule({ strict: true }))
	*/
	use(validation) {
		this.validations.push(VALIDATION in validation ? validation[VALIDATION]() : validation);
		return this;
	}
	/**
	* Enable/disable bail mode for this field.
	* In bail mode, field validations stop after the first error.
	*
	* @param state - Whether to enable bail mode
	* @returns This schema instance for method chaining
	*
	* @example
	* vine.string().bail(false) // Continue validation after first error
	* vine.number().bail(true)  // Stop after first error (default)
	*/
	bail(state) {
		this.options.bail = state;
		return this;
	}
	/**
	* Mark the field under validation as optional. An optional
	* field allows both null and undefined values.
	*/
	optional() {
		return new OptionalModifier$1(this);
	}
	/**
	* 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.
	*/
	nullable() {
		return new NullableModifier$1(this);
	}
	/**
	* Add meta to the field that can be retrieved once compiled.
	* It is also merged with the json-schema.
	*/
	meta(meta) {
		return new MetaModifier$1(this, meta);
	}
	/**
	* Apply transform on the final validated value. The transform method may
	* convert the value to any new datatype.
	*/
	transform(transformer) {
		return new TransformModifier(transformer, this);
	}
	/**
	* Compiles the literal schema type into a compiler node.
	* This method transforms the schema definition into a format
	* that the validation compiler can process.
	*
	* @param propertyName - Name of the property being compiled
	* @param refs - Reference store for the compiler
	* @param options - Parser options including camelCase conversion
	* @returns Compiled literal node with subtype information
	*/
	[PARSE](propertyName, refs, options) {
		return {
			type: "literal",
			subtype: this[SUBTYPE],
			fieldName: propertyName,
			...this.dataTypeValidator ? { dataTypeValidatorFnId: this.compileValidation(this.dataTypeValidator, refs).ruleFnId } : {},
			propertyName: options.toCamelCase ? camelcase(propertyName) : propertyName,
			bail: this.options.bail,
			allowNull: this.options.allowNull,
			isOptional: this.options.isOptional,
			parseFnId: this.options.parse ? refs.trackParser(this.options.parse) : void 0,
			validations: this.compileValidations(refs)
		};
	}
};
//#endregion
//#region src/schema/any/main.ts
/**
* VineAny represents a schema type that accepts any value without validation.
* It allows strings, numbers, booleans, arrays, objects, and any other type.
* Use this when you want to accept any input but still want to apply custom validations.
*
* @example
* const schema = vine.any()
*
* const result = await vine.validate({
*   schema,
*   data: 'any value, including objects and arrays'
* })
*/
var VineAny = class VineAny extends BaseLiteralType {
	/**
	* Creates a new VineAny instance with optional configuration.
	*
	* @param options - Field options like bail mode and nullability
	* @param validations - Initial set of validations to apply
	*/
	constructor(options, validations) {
		super(options, validations);
	}
	/**
	* The subtype identifier for the literal schema field
	*/
	[SUBTYPE] = "any";
	/**
	* Clones the VineAny schema type. The applied options
	* and validations are copied to the new instance.
	*
	* @returns A cloned instance of this VineAny schema
	*/
	clone() {
		return new VineAny(this.cloneOptions(), this.cloneValidations());
	}
	/**
	* Converts the schema to JSON Schema format.
	* Returns a schema with an anyOf constraint covering multiple types.
	*/
	toJSONSchema() {
		const schema = { anyOf: [
			{ type: "string" },
			{ type: "number" },
			{ type: "boolean" },
			{ type: "array" },
			{ type: "object" }
		] };
		for (const validation of this.validations) {
			if (!validation.rule.toJSONSchema) continue;
			validation.rule.toJSONSchema(schema, validation.options);
		}
		return schema;
	}
};
//#endregion
//#region src/schema/enum/rules.ts
/**
* Enum rule validates that a field's value is one of the pre-defined choices.
*
* The choices can be provided as a static array or as a function that returns
* an array, allowing for dynamic choice lists based on the field context.
*
* @example
* vine.string().use(enumRule({ choices: ['red', 'blue', 'green'] }))
*
* @example
* vine.string().use(enumRule({
*   choices: (field) => field.data.availableColors
* }))
*/
const enumRule = createRule(function enumList(value, options, field) {
	const choices = typeof options.choices === "function" ? options.choices(field) : options.choices;
	/**
	* Report error when value is not part of the pre-defined
	* options
	*/
	if (!choices.includes(value)) field.report(messages.enum, "enum", field, { choices });
}, { toJSONSchema: (schema, options) => {
	if (typeof options.choices === "function") return;
	schema.enum = options.choices;
} });
//#endregion
//#region src/schema/enum/main.ts
/**
* VineEnum represents an enum data type that performs validation
* against a pre-defined choices list. It ensures the input value
* matches one of the allowed enum values exactly.
*
* @template Values - The readonly array of allowed enum values
*
* @example
* const schema = vine.enum(['active', 'inactive', 'pending'] as const)
*
* const result = await vine.validate({
*   schema,
*   data: 'active' // Must be one of the defined values
* })
*/
var VineEnum = class VineEnum extends BaseLiteralType {
	/**
	* Static collection of all available validation rules for enums
	*/
	static rules = { enum: enumRule };
	/**
	* The allowed enum values or a function that returns them dynamically
	*/
	#values;
	/**
	* The subtype identifier for the literal schema field
	*/
	[SUBTYPE] = "enum";
	/**
	* Returns the enum choices, either static values or function.
	*
	* @returns The enum values or generator function
	*/
	getChoices() {
		return this.#values;
	}
	/**
	* Creates a new VineEnum instance with the specified allowed values.
	*
	* @param values - Array of allowed values or function returning allowed values
	* @param options - Field options like bail mode and nullability
	* @param validations - Initial set of validations to apply
	*/
	constructor(values, options, validations) {
		super(options, validations || [enumRule({ choices: values })]);
		this.#values = values;
	}
	/**
	* Clones the VineEnum schema type. The applied options
	* and validations are copied to the new instance.
	*
	* @returns A cloned instance of this VineEnum schema
	*/
	clone() {
		return new VineEnum(this.#values, this.cloneOptions(), this.cloneValidations());
	}
};
//#endregion
//#region src/schema/date/rules.ts
/**
* Validates the value to be a string or number formatted
* as per the expected date-time format.
*/
const dateRule = createRule(function date(value, options, field) {
	if (!field.isDefined) return false;
	if (typeof value !== "string" && typeof value !== "number") {
		field.report(messages.date, "date", field);
		return false;
	}
	const { dateTime, formats } = helpers.asDayJS(value, options.formats);
	/**
	* Ensure post parsing the datetime instance is valid
	*/
	if (!dateTime.isValid()) {
		field.report(messages.date, "date", field);
		return false;
	}
	field.$value = dateTime;
	field.$formats = formats;
	field.mutate(globalTransforms.date ? globalTransforms.date(dateTime.toDate()) : dateTime.toDate(), field);
	return true;
});
/**
* The equals rule compares the input value to be same
* as the expected value.
*
* By default, the comparions of day, month and years are performed
*/
const equalsRule$1 = createRule(function equals(_, options, field) {
	const compare = options.compare || "day";
	const format = options.format || field.$formats;
	const dateTime = field.$value;
	const expectedValue = typeof options.expectedValue === "function" ? options.expectedValue(field) : options.expectedValue;
	const { dateTime: expectedDateTime } = helpers.asDayJS(expectedValue, format);
	if (!expectedDateTime.isValid()) throw new Error(`Invalid datetime value "${expectedValue}" provided to the equals rule`);
	/**
	* Ensure both the dates are the same
	*/
	if (!dateTime.isSame(expectedDateTime, compare)) field.report(messages["date.equals"], "date.equals", field, {
		expectedValue,
		compare
	});
});
/**
* The after rule compares the input value to be after
* the expected value.
*
* By default, the comparions of day, month and years are performed.
*/
const afterRule = createRule(function after(_, options, field) {
	const compare = options.compare || "day";
	const format = options.format || field.$formats;
	const dateTime = field.$value;
	const expectedValue = typeof options.expectedValue === "function" ? options.expectedValue(field) : options.expectedValue;
	const expectedDateTime = expectedValue === "today" ? dayjs() : expectedValue === "tomorrow" ? dayjs().add(1, "day") : helpers.asDayJS(expectedValue, format).dateTime;
	if (!expectedDateTime.isValid()) throw new Error(`Invalid datetime value "${expectedValue}" provided to the after rule`);
	/**
	* Ensure the input is after the expected value
	*/
	if (!dateTime.isAfter(expectedDateTime, compare)) field.report(messages["date.after"], "date.after", field, {
		expectedValue,
		compare
	});
});
/**
* The after or equal rule compares the input value to be
* after or equal to the expected value.
*
* By default, the comparions of day, month and years are performed.
*/
const afterOrEqualRule = createRule(function afterOrEqual(_, options, field) {
	const compare = options.compare || "day";
	const format = options.format || field.$formats;
	const dateTime = field.$value;
	const expectedValue = typeof options.expectedValue === "function" ? options.expectedValue(field) : options.expectedValue;
	const expectedDateTime = expectedValue === "today" ? dayjs() : expectedValue === "tomorrow" ? dayjs().add(1, "day") : helpers.asDayJS(expectedValue, format).dateTime;
	if (!expectedDateTime.isValid()) throw new Error(`Invalid datetime value "${expectedValue}" provided to the afterOrEqual rule`);
	/**
	* Ensure both the dates are the same or the input
	* is after than the expected value.
	*/
	if (!dateTime.isSameOrAfter(expectedDateTime, compare)) field.report(messages["date.afterOrEqual"], "date.afterOrEqual", field, {
		expectedValue,
		compare
	});
});
/**
* The before rule compares the input value to be before
* the expected value.
*
* By default, the comparions of day, month and years are performed.
*/
const beforeRule = createRule(function before(_, options, field) {
	const compare = options.compare || "day";
	const format = options.format || field.$formats;
	const dateTime = field.$value;
	const expectedValue = typeof options.expectedValue === "function" ? options.expectedValue(field) : options.expectedValue;
	const expectedDateTime = expectedValue === "today" ? dayjs() : expectedValue === "yesterday" ? dayjs().subtract(1, "day") : helpers.asDayJS(expectedValue, format).dateTime;
	if (!expectedDateTime.isValid()) throw new Error(`Invalid datetime value "${expectedValue}" provided to the before rule`);
	/**
	* Ensure the input is before the expected value
	*/
	if (!dateTime.isBefore(expectedDateTime, compare)) field.report(messages["date.before"], "date.before", field, {
		expectedValue,
		compare
	});
});
/**
* The before or equal rule compares the input value to be
* before or equal to the expected value.
*
* By default, the comparions of day, month and years are performed.
*/
const beforeOrEqualRule = createRule(function beforeOrEqual(_, options, field) {
	const compare = options.compare || "day";
	const format = options.format || field.$formats;
	const dateTime = field.$value;
	const expectedValue = typeof options.expectedValue === "function" ? options.expectedValue(field) : options.expectedValue;
	const expectedDateTime = expectedValue === "today" ? dayjs() : expectedValue === "yesterday" ? dayjs().subtract(1, "day") : helpers.asDayJS(expectedValue, format).dateTime;
	if (!expectedDateTime.isValid()) throw new Error(`Invalid datetime value "${expectedValue}" provided to the beforeOrEqual rule`);
	/**
	* Ensure the input is same or before the expected value
	*/
	if (!dateTime.isSameOrBefore(expectedDateTime, compare)) field.report(messages["date.beforeOrEqual"], "date.beforeOrEqual", field, {
		expectedValue,
		compare
	});
});
/**
* The sameAs rule expects the input value to be same
* as the value of the other field.
*
* By default, the comparions of day, month and years are performed
*/
const sameAsRule$1 = createRule(function sameAs(_, options, field) {
	const compare = options.compare || "day";
	const dateTime = field.$value;
	const format = options.format || field.$formats;
	const expectedValue = helpers.getNestedValue(options.otherField, field);
	const expectedDateTime = helpers.asDayJS(expectedValue, format).dateTime;
	/**
	* Skip validation when the other field is not a valid
	* datetime. We will let the `date` rule on that
	* other field to handle the invalid date.
	*/
	if (!expectedDateTime.isValid()) return;
	/**
	* Ensure both the dates are the same
	*/
	if (!dateTime.isSame(expectedDateTime, compare)) field.report(messages["date.sameAs"], "date.sameAs", field, {
		otherField: options.otherField,
		expectedValue,
		compare
	});
});
/**
* The notSameAs rule expects the input value to be different
* from the other field's value
*
* By default, the comparions of day, month and years are performed
*/
const notSameAsRule$1 = createRule(function notSameAs(_, options, field) {
	const compare = options.compare || "day";
	const dateTime = field.$value;
	const format = options.format || field.$formats;
	const expectedValue = helpers.getNestedValue(options.otherField, field);
	const expectedDateTime = helpers.asDayJS(expectedValue, format).dateTime;
	/**
	* Skip validation when the other field is not a valid
	* datetime. We will let the `date` rule on that
	* other field to handle the invalid date.
	*/
	if (!expectedDateTime.isValid()) return;
	/**
	* Ensure both the dates are different
	*/
	if (dateTime.isSame(expectedDateTime, compare)) field.report(messages["date.notSameAs"], "date.notSameAs", field, {
		otherField: options.otherField,
		expectedValue,
		compare
	});
});
/**
* The afterField rule expects the input value to be after
* the other field's value.
*
* By default, the comparions of day, month and years are performed
*/
const afterFieldRule = createRule(function afterField(_, options, field) {
	const compare = options.compare || "day";
	const dateTime = field.$value;
	const format = options.format || field.$formats;
	const expectedValue = helpers.getNestedValue(options.otherField, field);
	const expectedDateTime = helpers.asDayJS(expectedValue, format).dateTime;
	/**
	* Skip validation when the other field is not a valid
	* datetime. We will let the `date` rule on that
	* other field to handle the invalid date.
	*/
	if (!expectedDateTime.isValid()) return;
	/**
	* Ensure the input date is after the other field's value
	*/
	if (!dateTime.isAfter(expectedDateTime, compare)) field.report(messages["date.afterField"], "date.afterField", field, {
		otherField: options.otherField,
		expectedValue,
		compare
	});
});
/**
* The afterOrSameAs rule expects the input value to be after
* or same as the other field's value.
*
* By default, the comparions of day, month and years are performed
*/
const afterOrSameAsRule = createRule(function afterOrSameAs(_, options, field) {
	const compare = options.compare || "day";
	const dateTime = field.$value;
	const format = options.format || field.$formats;
	const expectedValue = helpers.getNestedValue(options.otherField, field);
	const expectedDateTime = helpers.asDayJS(expectedValue, format).dateTime;
	/**
	* Skip validation when the other field is not a valid
	* datetime. We will let the `date` rule on that
	* other field to handle the invalid date.
	*/
	if (!expectedDateTime.isValid()) return;
	/**
	* Ensure the input date is same as or after the other field's value
	*/
	if (!dateTime.isSameOrAfter(expectedDateTime, compare)) field.report(messages["date.afterOrSameAs"], "date.afterOrSameAs", field, {
		otherField: options.otherField,
		expectedValue,
		compare
	});
});
/**
* The beforeField rule expects the input value to be before
* the other field's value.
*
* By default, the comparions of day, month and years are performed
*/
const beforeFieldRule = createRule(function beforeField(_, options, field) {
	const compare = options.compare || "day";
	const dateTime = field.$value;
	const format = options.format || field.$formats;
	const expectedValue = helpers.getNestedValue(options.otherField, field);
	const expectedDateTime = helpers.asDayJS(expectedValue, format).dateTime;
	/**
	* Skip validation when the other field is not a valid
	* datetime. We will let the `date` rule on that
	* other field to handle the invalid date.
	*/
	if (!expectedDateTime.isValid()) return;
	/**
	* Ensure the input date is before the other field's value
	*/
	if (!dateTime.isBefore(expectedDateTime, compare)) field.report(messages["date.beforeField"], "date.beforeField", field, {
		otherField: options.otherField,
		expectedValue,
		compare
	});
});
/**
* The beforeOrSameAs rule expects the input value to be before
* or same as the other field's value.
*
* By default, the comparions of day, month and years are performed
*/
const beforeOrSameAsRule = createRule(function beforeOrSameAs(_, options, field) {
	const compare = options.compare || "day";
	const dateTime = field.$value;
	const format = options.format || field.$formats;
	const expectedValue = helpers.getNestedValue(options.otherField, field);
	const expectedDateTime = helpers.asDayJS(expectedValue, format).dateTime;
	/**
	* Skip validation when the other field is not a valid
	* datetime. We will let the `date` rule on that
	* other field to handle the invalid date.
	*/
	if (!expectedDateTime.isValid()) return;
	/**
	* Ensure the input date is before or same as the other field's value
	*/
	if (!dateTime.isSameOrBefore(expectedDateTime, compare)) field.report(messages["date.beforeOrSameAs"], "date.beforeOrSameAs", field, {
		otherField: options.otherField,
		expectedValue,
		compare
	});
});
/**
* The weekend rule ensures the date falls on a weekend
*/
const weekendRule = createRule(function weekend(_, __, field) {
	const day = field.$value.day();
	if (day !== 0 && day !== 6) field.report(messages["date.weekend"], "date.weekend", field);
});
/**
* The weekday rule ensures the date falls on a weekday
*/
const weekdayRule = createRule(function weekday(_, __, field) {
	const day = field.$value.day();
	if (day === 0 || day === 6) field.report(messages["date.weekday"], "date.weekday", field);
});
//#endregion
//#region src/schema/date/main.ts
/**
* VineDate represents a Date object created by parsing a string or number value as a date.
* It accepts various date formats and converts them to JavaScript Date objects,
* with comprehensive validation rules for date comparisons and ranges.
*
* @example
* const schema = vine.date()
*   .after('today')
*   .before('2025-12-31')
*
* const result = await vine.validate({
*   schema,
*   data: '2025-06-15'
* })
*/
var VineDate = class VineDate extends BaseLiteralType {
	/**
	* Sets a global transformer function for all date values.
	* The transformer is applied to every validated date value.
	*
	* @param transformer - Function that transforms a Date object to a custom type
	*
	* @example
	* VineDate.transform((value) => value.toISOString())
	*/
	static transform(transformer) {
		globalTransforms.date = transformer;
	}
	/**
	* Static collection of all available validation rules for dates
	*/
	static rules = {
		equals: equalsRule$1,
		after: afterRule,
		afterOrEqual: afterOrEqualRule,
		before: beforeRule,
		beforeOrEqual: beforeOrEqualRule,
		sameAs: sameAsRule$1,
		notSameAs: notSameAsRule$1,
		afterField: afterFieldRule,
		afterOrSameAs: afterOrSameAsRule,
		beforeField: beforeFieldRule,
		beforeOrSameAs: beforeOrSameAsRule,
		weekend: weekendRule,
		weekday: weekdayRule
	};
	/**
	* Unique name identifier for union type resolution
	*/
	[UNIQUE_NAME] = "vine.date";
	/**
	* The subtype identifier for the literal schema field
	*/
	[SUBTYPE] = "date";
	/**
	* Type checker function to determine if a value can be parsed as a date.
	* Required for "unionOfTypes" functionality.
	*
	* @param value - The value to check
	* @returns True if the value can be parsed as a valid date
	*/
	[IS_OF_TYPE] = (value) => {
		if (typeof value !== "string") return false;
		return helpers.asDayJS(value, this.options.formats).dateTime.isValid();
	};
	/**
	* Creates a new VineDate instance with optional configuration.
	*
	* @param options - Field options including date formats and nullability
	* @param validations - Initial set of validations to apply
	*/
	constructor(options, validations) {
		super(options, validations || []);
		this.dataTypeValidator = dateRule(options || {});
	}
	/**
	* Validates the date to be equal to the expected value.
	* By default, compares day, month, and year.
	*
	* @param expectedValue - The expected date value or 'today'
	* @param options - Comparison options (compare unit and format)
	* @returns This date schema instance for method chaining
	*
	* @example
	* vine.date().equals('2025-01-01')
	* vine.date().equals('today')
	* vine.date().equals('2025-01-01', { compare: 'month' })
	*/
	equals(expectedValue, options) {
		return this.use(equalsRule$1({
			expectedValue,
			...options
		}));
	}
	/**
	* Validates the date to be after the expected value.
	* By default, compares day, month, and year.
	*
	* @param expectedValue - The expected date value, 'today', or 'tomorrow'
	* @param options - Comparison options (compare unit and format)
	* @returns This date schema instance for method chaining
	*
	* @example
	* vine.date().after('today')
	* vine.date().after('2025-01-01')
	* vine.date().after('tomorrow', { compare: 'hour' })
	*/
	after(expectedValue, options) {
		return this.use(afterRule({
			expectedValue,
			...options
		}));
	}
	/**
	* Validates the date to be after or equal to the expected value.
	* By default, compares day, month, and year.
	*
	* @param expectedValue - The expected date value, 'today', or 'tomorrow'
	* @param options - Comparison options (compare unit and format)
	* @returns This date schema instance for method chaining
	*
	* @example
	* vine.date().afterOrEqual('today')
	* vine.date().afterOrEqual('2025-01-01')
	*/
	afterOrEqual(expectedValue, options) {
		return this.use(afterOrEqualRule({
			expectedValue,
			...options
		}));
	}
	/**
	* Validates the date to be before the expected value.
	* By default, compares day, month, and year.
	*
	* @param expectedValue - The expected date value, 'today', or 'yesterday'
	* @param options - Comparison options (compare unit and format)
	* @returns This date schema instance for method chaining
	*
	* @example
	* vine.date().before('today')
	* vine.date().before('2025-12-31')
	* vine.date().before('yesterday')
	*/
	before(expectedValue, options) {
		return this.use(beforeRule({
			expectedValue,
			...options
		}));
	}
	/**
	* Validates the date to be before or equal to the expected value.
	* By default, compares day, month, and year.
	*
	* @param expectedValue - The expected date value, 'today', or 'yesterday'
	* @param options - Comparison options (compare unit and format)
	* @returns This date schema instance for method chaining
	*
	* @example
	* vine.date().beforeOrEqual('today')
	* vine.date().beforeOrEqual('2025-12-31')
	*/
	beforeOrEqual(expectedValue, options) {
		return this.use(beforeOrEqualRule({
			expectedValue,
			...options
		}));
	}
	/**
	* Validates the date to be equal to another field's value.
	* By default, compares day, month, and year.
	*
	* @param otherField - The name of the other field to compare with
	* @param options - Comparison options (compare unit and format)
	* @returns This date schema instance for method chaining
	*
	* @example
	* vine.date().sameAs('startDate')
	* vine.date().sameAs('birthDate', { compare: 'month' })
	*/
	sameAs(otherField, options) {
		return this.use(sameAsRule$1({
			otherField,
			...options
		}));
	}
	/**
	* Validates the date to be different from another field's value.
	* By default, compares day, month, and year.
	*
	* @param otherField - The name of the other field to compare with
	* @param options - Comparison options (compare unit and format)
	* @returns This date schema instance for method chaining
	*
	* @example
	* vine.date().notSameAs('endDate')
	* vine.date().notSameAs('previousDate')
	*/
	notSameAs(otherField, options) {
		return this.use(notSameAsRule$1({
			otherField,
			...options
		}));
	}
	/**
	* Validates the date to be after another field's value.
	* By default, compares day, month, and year.
	*
	* @param otherField - The name of the other field to compare with
	* @param options - Comparison options (compare unit and format)
	* @returns This date schema instance for method chaining
	*
	* @example
	* vine.date().afterField('startDate')
	* vine.date().afterField('createdAt', { compare: 'minute' })
	*/
	afterField(otherField, options) {
		return this.use(afterFieldRule({
			otherField,
			...options
		}));
	}
	/**
	* Validates the date to be after or equal to another field's value.
	* By default, compares day, month, and year.
	*
	* @param otherField - The name of the other field to compare with
	* @param options - Comparison options (compare unit and format)
	* @returns This date schema instance for method chaining
	*
	* @example
	* vine.date().afterOrSameAs('startDate')
	*/
	afterOrSameAs(otherField, options) {
		return this.use(afterOrSameAsRule({
			otherField,
			...options
		}));
	}
	/**
	* Validates the date to be before another field's value.
	* By default, compares day, month, and year.
	*
	* @param otherField - The name of the other field to compare with
	* @param options - Comparison options (compare unit and format)
	* @returns This date schema instance for method chaining
	*
	* @example
	* vine.date().beforeField('endDate')
	* vine.date().beforeField('expiresAt')
	*/
	beforeField(otherField, options) {
		return this.use(beforeFieldRule({
			otherField,
			...options
		}));
	}
	/**
	* Validates the date to be before or equal to another field's value.
	* By default, compares day, month, and year.
	*
	* @param otherField - The name of the other field to compare with
	* @param options - Comparison options (compare unit and format)
	* @returns This date schema instance for method chaining
	*
	* @example
	* vine.date().beforeOrSameAs('endDate')
	*/
	beforeOrSameAs(otherField, options) {
		return this.use(beforeOrSameAsRule({
			otherField,
			...options
		}));
	}
	/**
	* Validates the date to fall on a weekend (Saturday or Sunday).
	*
	* @returns This date schema instance for method chaining
	*
	* @example
	* vine.date().weekend()
	*/
	weekend() {
		return this.use(weekendRule());
	}
	/**
	* Validates the date to fall on a weekday (Monday to Friday).
	*
	* @returns This date schema instance for method chaining
	*
	* @example
	* vine.date().weekday()
	*/
	weekday() {
		return this.use(weekdayRule());
	}
	/**
	* Clones the VineDate schema type. The applied options
	* and validations are copied to the new instance.
	*
	* @returns A cloned instance of this VineDate schema
	*/
	clone() {
		return new VineDate(this.cloneOptions(), this.cloneValidations());
	}
};
//#endregion
//#region src/schema/null/main.ts
/**
* VineNull represents a schema type that only accepts null values.
* Typically used inside union types to explicitly allow null as a valid value.
*
* @example
* const schema = vine.union([
*   vine.string(),
*   vine.null()
* ])
*
* const result = await vine.validate({
*   schema,
*   data: null
* })
*/
var VineNull = class VineNull {
	/**
	* The subtype identifier for the literal schema field
	*/
	[SUBTYPE] = "null";
	/**
	* Unique name identifier for union type resolution
	*/
	[UNIQUE_NAME] = "vine.null";
	/**
	* Type checker function to determine if a value is null.
	* Required for "unionOfTypes" functionality.
	*
	* @param value - The value to check
	* @returns True if the value is null
	*/
	[IS_OF_TYPE] = (value) => {
		return value === null;
	};
	/**
	* Field configuration options
	*/
	options;
	/**
	* Creates a new VineNull instance with optional configuration.
	*
	* @param options - Field options like bail mode (defaults allow null)
	*/
	constructor(options) {
		this.options = {
			bail: true,
			allowNull: true,
			isOptional: false,
			...options
		};
	}
	/**
	* Creates a shallow clone of the field options.
	*/
	cloneOptions() {
		return { ...this.options };
	}
	/**
	* Clones the VineNull schema type. The applied options
	* are copied to the new instance.
	*
	* @returns A cloned instance of this VineNull schema
	*/
	clone() {
		return new VineNull(this.cloneOptions());
	}
	/**
	* Converts the schema to JSON Schema format.
	* Returns a schema with type 'null'.
	*/
	toJSONSchema() {
		return { type: "null" };
	}
	/**
	* Compiles the schema type to a compiler node for validation.
	*
	* @param propertyName - The name of the property being validated
	* @param refs - Reference store for tracking parsers and validators
	* @param options - Parser options including camelCase conversion
	*/
	[PARSE](propertyName, refs, options) {
		return {
			type: "literal",
			subtype: this[SUBTYPE],
			fieldName: propertyName,
			propertyName: options.toCamelCase ? camelcase(propertyName) : propertyName,
			bail: this.options.bail,
			allowNull: this.options.allowNull,
			isOptional: this.options.isOptional,
			parseFnId: this.options.parse ? refs.trackParser(this.options.parse) : void 0,
			validations: []
		};
	}
};
//#endregion
//#region src/schema/union/conditional.ts
/**
* Represents a union conditional type. A conditional is a predicate
* function combined with a schema that is applied when the predicate
* evaluates to true.
*
* Each conditional acts as a branch in the union, determining which
* validation schema should be applied based on runtime conditions.
*
* @template Schema - The schema type to apply when condition is met
*/
var UnionConditional = class {
	/**
	* Schema to apply when conditional is true
	*/
	#schema;
	/**
	* Predicate function to evaluate
	*/
	#conditional;
	/**
	* Creates a new UnionConditional instance.
	*
	* @param conditional - Function that determines if this branch matches
	* @param schema - Schema to apply when the conditional returns true
	*/
	constructor(conditional, schema) {
		this.#schema = schema;
		this.#conditional = conditional;
	}
	/**
	* Transforms the conditional's schema into JSON Schema format.
	*/
	toJSONSchema() {
		return this.#schema.toJSONSchema?.();
	}
	/**
	* Compiles the conditional to a union conditional node.
	*
	* @param propertyName - The name of the property being validated
	* @param refs - Reference store for tracking validators and conditionals
	* @param options - Parser options including camelCase transformation
	*/
	[PARSE](propertyName, refs, options) {
		return {
			conditionalFnRefId: refs.trackConditional(this.#conditional),
			schema: this.#schema[PARSE](propertyName, refs, options)
		};
	}
};
//#endregion
//#region src/schema/optional/main.ts
/**
* 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.
*
* @template Output - The output type when the value is defined
*
* @example
* const schema = vine.object({
*   name: vine.string().optional()
* })
*
* @example
* const schema = vine.unionOfTypes([
*   vine.string(),
*   vine.optional()
* ])
*/
var VineOptional = class VineOptional extends ConditionalValidations {
	/**
	* The subtype identifier for the literal schema field
	*/
	[SUBTYPE] = "optional";
	/**
	* Unique name identifier for union type resolution
	*/
	[UNIQUE_NAME] = "vine.optional";
	/**
	* Type checker function to determine if a value is optional (null or undefined).
	* Required for "unionOfTypes" functionality.
	*
	* @param value - The value to check
	*/
	[IS_OF_TYPE] = (value) => {
		return value === null || value === void 0;
	};
	/**
	* Field options controlling validation behavior
	*/
	options;
	/**
	* Set of validations to run on the field
	*/
	validations;
	/**
	* Creates a new VineOptional instance.
	*
	* @param options - Field options like bail mode and nullability
	* @param validations - Initial set of validations to apply
	*/
	constructor(options, validations) {
		super();
		this.options = {
			bail: true,
			allowNull: false,
			isOptional: true,
			...options
		};
		this.validations = validations || [];
	}
	/**
	* Shallow clones the validations. Since there are no APIs to mutate
	* the validation options, we can safely copy them by reference.
	*
	* @returns Array of cloned validation objects
	*/
	cloneValidations() {
		return this.validations.map((validation) => {
			return {
				options: validation.options,
				rule: validation.rule
			};
		});
	}
	/**
	* Shallow clones the field options.
	*
	* @returns Cloned field options object
	*/
	cloneOptions() {
		return { ...this.options };
	}
	/**
	* Compiles validations into a format suitable for the compiler.
	*
	* @param refs - Reference store for tracking validators
	*/
	compileValidations(refs) {
		return this.validations.map((validation) => {
			return {
				ruleFnId: refs.track({
					validator: validation.rule.validator,
					options: validation.options
				}),
				implicit: validation.rule.implicit,
				isAsync: validation.rule.isAsync
			};
		});
	}
	/**
	* 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.
	*
	* @param callback - Parser function to transform the input value
	*/
	parse(callback) {
		this.options.parse = callback;
		return this;
	}
	/**
	* Push a validation to the validations chain.
	*
	* @param validation - Validation rule or rule builder to add
	*/
	use(validation) {
		this.validations.push(VALIDATION in validation ? validation[VALIDATION]() : validation);
		return this;
	}
	/**
	* Enable/disable the bail mode. In bail mode, the field validations
	* are stopped after the first error.
	*
	* @param state - True to enable bail mode, false to disable
	*/
	bail(state) {
		this.options.bail = state;
		return this;
	}
	/**
	* Clones the VineOptional schema type. The applied options
	* and validations are copied to the new instance.
	*
	* @returns A cloned instance of this VineOptional schema
	*/
	clone() {
		return new VineOptional(this.cloneOptions(), this.cloneValidations());
	}
	/**
	* 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.
	*/
	nullable() {
		return new VineOptional({
			...this.options,
			allowNull: true
		});
	}
	/**
	* Transforms into JSON Schema format.
	*/
	toJSONSchema() {
		return {};
	}
	/**
	* Compiles the schema type to a compiler node.
	*
	* @param propertyName - The name of the property being validated
	* @param refs - Reference store for tracking validators and parsers
	* @param options - Parser options including camelCase transformation
	*/
	[PARSE](propertyName, refs, options) {
		return {
			type: "literal",
			subtype: this[SUBTYPE],
			fieldName: propertyName,
			propertyName: options.toCamelCase ? camelcase(propertyName) : propertyName,
			bail: this.options.bail,
			allowNull: this.options.allowNull,
			isOptional: this.options.isOptional,
			parseFnId: this.options.parse ? refs.trackParser(this.options.parse) : void 0,
			validations: this.compileValidations(refs)
		};
	}
};
//#endregion
//#region src/schema/union/main.ts
/**
* Vine union represents a union data type. A union is a collection
* of conditionals and each condition has an associated schema.
*
* Unions allow you to define validation logic where different schemas
* are applied based on runtime conditions. Each conditional is evaluated
* in order, and the first matching condition's schema is used for validation.
*
* @template Conditional - The union conditional type extending UnionConditional
*
* @example
* const schema = vine.object({
*   userType: vine.string(),
*   data: vine.union([
*     vine.union.if(
*       (value) => value.userType === 'admin',
*       vine.object({ permissions: vine.array(vine.string()) })
*     ),
*     vine.union.else(
*       vine.object({ role: vine.string() })
*     )
*   ])
* })
*/
var VineUnion = class VineUnion {
	/**
	* Array of conditional branches to evaluate
	*/
	#conditionals;
	/**
	* Callback to invoke when no conditional matches
	*/
	#otherwiseCallback = (_, field) => {
		field.report(messages.union, "union", field);
	};
	/**
	* Creates a new VineUnion instance with the specified conditionals.
	*
	* @param conditionals - Array of conditional branches to evaluate
	*/
	constructor(conditionals) {
		this.#conditionals = conditionals;
	}
	/**
	* Mark the field under validation as optional. An optional
	* field allows both null and undefined values.
	*/
	optional() {
		const optional = new VineOptional();
		return new VineUnion([new UnionConditional(optional[IS_OF_TYPE], optional), ...this.#conditionals]);
	}
	/**
	* 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.
	*/
	nullable() {
		const nullable = new VineNull();
		return new VineUnion([new UnionConditional(nullable[IS_OF_TYPE], nullable), ...this.#conditionals]);
	}
	/**
	* Define a fallback method to invoke when all of the union conditions
	* fail. You may use this method to report an error.
	*/
	otherwise(callback) {
		this.#otherwiseCallback = callback;
		return this;
	}
	/**
	* Transforms into JSONSchema.
	*/
	toJSONSchema() {
		return { anyOf: this.#conditionals.map((conditional) => conditional.toJSONSchema()).filter(Boolean) };
	}
	/**
	* Clones the VineUnion schema type.
	*/
	clone() {
		const cloned = new VineUnion(this.#conditionals);
		cloned.otherwise(this.#otherwiseCallback);
		return cloned;
	}
	/**
	* Compiles the union schema to a compiler node.
	*
	* @param propertyName - The name of the property being validated
	* @param refs - Reference store for tracking validators and conditionals
	* @param options - Parser options including camelCase transformation
	*/
	[PARSE](propertyName, refs, options) {
		return {
			type: "union",
			fieldName: propertyName,
			propertyName: options.toCamelCase ? camelcase(propertyName) : propertyName,
			elseConditionalFnRefId: refs.trackConditional(this.#otherwiseCallback),
			conditions: this.#conditionals.map((conditional) => conditional[PARSE](propertyName, refs, options))
		};
	}
};
//#endregion
//#region src/schema/union/builder.ts
/**
* Create a new union schema type. A union is a collection of conditionals
* and schema associated with it.
*
* Unions evaluate conditionals in order and apply the first matching schema.
* Use `union.if()` to define conditional branches and `union.else()` for
* the default fallback.
*
* @template Conditional - The union conditional type
* @param conditionals - Array of conditional branches to evaluate
*
* @example
* const schema = vine.union([
*   vine.union.if(
*     (value) => typeof value === 'string',
*     vine.string()
*   ),
*   vine.union.if(
*     (value) => typeof value === 'number',
*     vine.number()
*   )
* ])
*/
function union(conditionals) {
	return new VineUnion(conditionals);
}
/**
* Wrap a schema inside a conditional branch. The condition is evaluated
* at runtime, and if it returns a truthy value, the associated schema
* is used for validation.
*
* @template Schema - The schema type to apply when condition matches
* @param conditon - Function that evaluates whether this branch should be used
* @param schema - The schema to apply if the condition is true
*
* @example
* vine.union.if(
*   (value) => value.type === 'email',
*   vine.object({ email: vine.string().email() })
* )
*/
union.if = function unionIf(conditon, schema) {
	return new UnionConditional(conditon, schema);
};
/**
* Wrap a schema inside an else (default) conditional. This branch
* always matches and should be placed last in the union conditionals array.
*
* @template Schema - The schema type to apply as default
* @param schema - The schema to apply when no other conditions match
*
* @example
* vine.union([
*   vine.union.if((value) => value.type === 'admin', adminSchema),
*   vine.union.else(userSchema)
* ])
*/
union.else = function unionElse(schema) {
	return new UnionConditional(() => true, schema);
};
//#endregion
//#region src/schema/base/main.ts
/**
* Modifies the schema type to allow null values in addition to the
* original schema type. This is useful for optional database fields
* or API responses that may contain null values.
*
* @template Schema - The underlying schema type to modify
*
* @example
* const schema = vine.string().nullable()
* // Accepts: "hello", null
* // Rejects: undefined, 123
*/
var NullableModifier = class NullableModifier {
	allowNull = true;
	get isOptional() {
		return this.#parent.isOptional;
	}
	/**
	* Reference to the parent schema being modified
	*/
	#parent;
	/**
	* Creates a new nullable modifier wrapping the given schema.
	*
	* @param parent - The schema to make nullable
	*/
	constructor(parent) {
		this.#parent = parent;
	}
	/**
	* Mark the field under validation as optional. An optional
	* field allows both null and undefined values.
	*
	* @returns A new OptionalModifier wrapping this nullable schema
	*/
	optional() {
		return new OptionalModifier(this);
	}
	/**
	* Add meta to the field that can be retrieved once compiled.
	* It is also merged with the json-schema.
	*/
	meta(meta) {
		return new MetaModifier(this, meta);
	}
	/**
	* Creates a fresh instance of the underlying schema type
	* and wraps it inside the nullable modifier.
	*
	* @returns A cloned instance of this nullable modifier
	*/
	clone() {
		return new NullableModifier(this.#parent.clone());
	}
	toJSONSchema() {
		const schema = this.#parent.toJSONSchema?.();
		if (!schema) return { type: "null" };
		if (schema.anyOf) {
			schema.anyOf.push({ type: "null" });
			return schema;
		}
		if (schema.type === void 0) {
			schema.type = "null";
			return schema;
		}
		if (typeof schema.type === "string") {
			schema.type = [schema.type, "null"];
			return schema;
		}
		if (Array.isArray(schema.type)) {
			schema.type.push("null");
			return schema;
		}
		return schema;
	}
	/**
	* Compiles to compiler node by delegating to the parent schema
	* and setting the allowNull flag.
	*
	* @param propertyName - Name of the property being compiled
	* @param refs - Reference store for the compiler
	* @param options - Parser options
	* @returns Compiled compiler node with null support
	*/
	[PARSE](propertyName, refs, options) {
		const output = this.#parent[PARSE](propertyName, refs, options);
		if (output.type !== "union") output.allowNull = true;
		return output;
	}
};
var MetaModifier = class MetaModifier {
	get allowNull() {
		return this.#parent.allowNull;
	}
	get isOptional() {
		return this.#parent.isOptional;
	}
	#parent;
	#meta;
	constructor(parent, meta) {
		this.#parent = parent;
		this.#meta = meta;
	}
	/**
	* Creates a fresh instance of the underlying schema type
	* and wraps it inside the meta modifier
	*/
	clone() {
		return new MetaModifier(this.#parent.clone(), this.#meta);
	}
	toJSONSchema() {
		return {
			...this.#parent.toJSONSchema?.() ?? {},
			...this.#meta
		};
	}
	/**
	* Compiles to compiler node by delegating to the parent schema
	* and setting the allowNull flag.
	*
	* @param propertyName - Name of the property being compiled
	* @param refs - Reference store for the compiler
	* @param options - Parser options
	* @returns Compiled compiler node with null support
	*/
	[PARSE](propertyName, refs, options) {
		return this.#parent[PARSE](propertyName, refs, options);
	}
};
/**
* Modifies the schema type to allow undefined values in addition to the
* original schema type. This is useful for form fields that may not be
* present in the submitted data.
*
* @template Schema - The underlying schema type to modify
*
* @example
* const schema = vine.string().optional()
* // Accepts: "hello", undefined
* // Rejects: null (unless also nullable), 123
*/
var OptionalModifier = class OptionalModifier extends ConditionalValidations {
	isOptional = true;
	get allowNull() {
		return this.#parent.allowNull;
	}
	/**
	* Reference to the parent schema being modified
	*/
	#parent;
	/**
	* List of validations to apply to non-undefined values
	*/
	validations;
	/**
	* Creates a new optional modifier wrapping the given schema.
	*
	* @param parent - The schema to make optional
	* @param validations - Optional list of validations to apply
	*/
	constructor(parent, validations) {
		super();
		this.#parent = parent;
		this.validations = validations || [];
	}
	/**
	* Shallow clones the validations. Since, there are no API's to mutate
	* the validation options, we can safely copy them by reference.
	*
	* @returns Cloned array of validations
	*/
	cloneValidations() {
		return this.validations.map((validation) => {
			return {
				options: validation.options,
				rule: validation.rule
			};
		});
	}
	/**
	* Compiles validations into a format suitable for the validator compiler.
	*
	* @param refs - Reference store for tracking validation functions
	* @returns Compiled validation definitions
	*/
	compileValidations(refs) {
		return this.validations.map((validation) => {
			return {
				ruleFnId: refs.track({
					validator: validation.rule.validator,
					options: validation.options
				}),
				name: validation.rule.name,
				implicit: validation.rule.implicit,
				isAsync: validation.rule.isAsync
			};
		});
	}
	/**
	* 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.
	*/
	nullable() {
		return new NullableModifier(this);
	}
	/**
	* Add meta to the field that can be retrieved once compiled.
	* It is also merged with the json-schema.
	*/
	meta(meta) {
		return new MetaModifier(this, meta);
	}
	/**
	* Push a validation to the validations chain.
	*/
	use(validation) {
		this.validations.push(VALIDATION in validation ? validation[VALIDATION]() : validation);
		return this;
	}
	/**
	* Creates a fresh instance of the underlying schema type
	* and wraps it inside the optional modifier
	*/
	clone() {
		return new OptionalModifier(this.#parent.clone(), this.cloneValidations());
	}
	toJSONSchema() {
		return { ...this.#parent.toJSONSchema() };
	}
	/**
	* Compiles to compiler node
	*/
	[PARSE](propertyName, refs, options) {
		const output = this.#parent[PARSE](propertyName, refs, options);
		if (output.type !== "union") {
			output.isOptional = true;
			output.validations = output.validations.concat(this.compileValidations(refs));
		}
		return output;
	}
};
/**
* The BaseType class abstracts the repetitive parts of creating
* a custom schema type. It provides common functionality like validation
* chaining, optional/nullable modifiers, and compilation logic.
*
* @template Input - The expected input type for this schema
* @template Output - The output type after validation and transformation
* @template CamelCaseOutput - The output type with camelCase field names
*
* @example
* class CustomStringType extends BaseType<string, string, string> {
*   [PARSE](propertyName: string, refs: RefsStore, options: ParserOptions) {
*     return { type: 'literal', name: propertyName, ... }
*   }
*   clone() { return new CustomStringType() }
* }
*/
var BaseType = class extends Macroable {
	/**
	* The child class must implement the toJSONSchema method to
	* support converting into a JSON Schema.
	*
	* Otherwise it returns an empty schema which is considered as any.
	*
	* @returns JSON Schema
	*/
	toJSONSchema() {
		return {};
	}
	/**
	* Set of validations to run on the field value
	*/
	validations;
	/**
	* Configuration options for this field
	*/
	options;
	/**
	* Creates a new BaseType instance with optional configuration.
	*
	* @param options - Field options like bail mode and nullability
	* @param validations - Initial set of validations to apply
	*/
	constructor(options, validations) {
		super();
		this.options = options || {
			bail: true,
			allowNull: false,
			isOptional: false
		};
		this.validations = validations || [];
	}
	/**
	* Shallow clones the validations. Since, there are no API's to mutate
	* the validation options, we can safely copy them by reference.
	*/
	cloneValidations() {
		return this.validations.map((validation) => {
			return {
				options: validation.options,
				rule: validation.rule
			};
		});
	}
	/**
	* Shallow clones the options
	*/
	cloneOptions() {
		return { ...this.options };
	}
	/**
	* Compiles validations
	*/
	compileValidations(refs) {
		return this.validations.map((validation) => {
			return {
				ruleFnId: refs.track({
					validator: validation.rule.validator,
					options: validation.options
				}),
				name: validation.rule.name,
				implicit: validation.rule.implicit,
				isAsync: validation.rule.isAsync
			};
		});
	}
	/**
	* 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.
	*
	* @param callback - Parser function to transform the input value
	* @returns This schema instance for method chaining
	*
	* @example
	* vine.string().parse((value) => {
	*   return typeof value === 'string' ? value.trim() : value
	* })
	*/
	parse(callback) {
		this.options.parse = callback;
		return this;
	}
	/**
	* Push a validation to the validations chain.
	*
	* @param validation - Validation rule or rule builder to add
	* @returns This schema instance for method chaining
	*
	* @example
	* vine.string().use(vine.createRule((value) => {
	*   return value.length > 0
	* }))
	*/
	use(validation) {
		this.validations.push(VALIDATION in validation ? validation[VALIDATION]() : validation);
		return this;
	}
	/**
	* Enable/disable the bail mode. In bail mode, the field validations
	* are stopped after the first error.
	*
	* @param state - Whether to enable bail mode
	* @returns This schema instance for method chaining
	*/
	bail(state) {
		this.options.bail = state;
		return this;
	}
	/**
	* Mark the field under validation as optional. An optional
	* field allows both null and undefined values.
	*
	* @returns A new OptionalModifier wrapping this schema
	*/
	optional() {
		return new OptionalModifier(this);
	}
	/**
	* 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.
	*
	* @returns A new NullableModifier wrapping this schema
	*/
	nullable() {
		return new NullableModifier(this);
	}
	/**
	* Add meta to the field that can be retrieved once compiled.
	* It is also merged with the json-schema.
	*/
	meta(meta) {
		return new MetaModifier(this, meta);
	}
};
//#endregion
//#region src/schema/tuple/main.ts
/**
* VineTuple represents a fixed-length array where each position has a specific schema type.
* Unlike VineArray which uses the same schema for all elements, tuples allow different
* types at different positions, similar to TypeScript tuples.
*
* @template Schema - Array of schema types for each tuple position
* @template Input - Expected input type for the tuple
* @template Output - Output type after validation and transformation
* @template CamelCaseOutput - Output type with camelCase property names
*
* @example
* const schema = vine.tuple([
*   vine.string(),
*   vine.number(),
*   vine.boolean()
* ])
*
* const result = await vine.validate({
*   schema,
*   data: ['hello', 42, true]
* })
*/
var VineTuple = class VineTuple extends BaseType {
	/**
	* Array of schemas defining the type for each tuple position
	*/
	#schemas;
	/**
	* Whether to allow additional elements beyond the defined tuple length
	*/
	#allowUnknownProperties = false;
	/**
	* Unique name identifier for union type resolution
	*/
	[UNIQUE_NAME] = "vine.array";
	/**
	* Type checker function to determine if a value is an array.
	* Required for "unionOfTypes" functionality.
	*
	* @param value - The value to check
	* @returns True if the value is an array
	*/
	[IS_OF_TYPE] = (value) => {
		return Array.isArray(value);
	};
	/**
	* Creates a new VineTuple instance with position-specific schemas.
	*
	* @param schemas - Array of schemas defining validation for each tuple position
	* @param options - Field options like bail mode and nullability
	* @param validations - Initial set of validations to apply
	*/
	constructor(schemas, options, validations) {
		super(options, validations);
		this.#schemas = schemas;
	}
	/**
	* Allows additional elements beyond the defined tuple length to pass through validation.
	* By default, tuples enforce exact length matching. This method relaxes that constraint.
	*
	* @returns This tuple schema with unknown properties allowed
	*
	* @example
	* const schema = vine.tuple([
	*   vine.string(),
	*   vine.number()
	* ]).allowUnknownProperties()
	*
	* // Now ['hello', 42, 'extra'] will pass validation
	*/
	allowUnknownProperties() {
		this.#allowUnknownProperties = true;
		return this;
	}
	/**
	* Clones the VineTuple schema including all position schemas, validations, and options.
	*
	* @returns A cloned instance of this VineTuple schema
	*/
	clone() {
		const cloned = new VineTuple(this.#schemas.map((schema) => schema.clone()), this.cloneOptions(), this.cloneValidations());
		if (this.#allowUnknownProperties) cloned.allowUnknownProperties();
		return cloned;
	}
	/**
	* Converts the tuple schema to JSON Schema format.
	*
	* @returns JSON Schema representation of this tuple
	*/
	toJSONSchema() {
		const items = [];
		for (const item of this.#schemas) {
			if (!item.toJSONSchema) continue;
			items.push(item.toJSONSchema());
		}
		const schema = {
			type: "array",
			minItems: this.#schemas.length,
			maxItems: this.#schemas.length,
			additionalItems: false,
			items
		};
		for (const validation of this.validations) {
			if (!validation.rule.toJSONSchema) continue;
			validation.rule.toJSONSchema(schema, validation.options);
		}
		return schema;
	}
	/**
	* Compiles the tuple schema to a compiler node for validation.
	*
	* @param propertyName - Name of the property being compiled
	* @param refs - Reference store for the compiler
	* @param options - Parser options
	* @returns Compiled tuple node for validation
	*/
	[PARSE](propertyName, refs, options) {
		return {
			type: "tuple",
			fieldName: propertyName,
			propertyName: options.toCamelCase ? camelcase(propertyName) : propertyName,
			bail: this.options.bail,
			allowNull: this.options.allowNull,
			isOptional: this.options.isOptional,
			allowUnknownProperties: this.#allowUnknownProperties,
			parseFnId: this.options.parse ? refs.trackParser(this.options.parse) : void 0,
			validations: this.compileValidations(refs),
			properties: this.#schemas.map((schema, index) => schema[PARSE](String(index), refs, options))
		};
	}
};
//#endregion
//#region src/schema/array/rules.ts
/**
* Enforce a minimum length on an array field.
*
* Validates that an array contains at least the specified number of elements.
*
* @example
* vine.array(vine.string()).minLength(2)
*/
const minLengthRule$2 = createRule(function minLength(value, options, field) {
	/**
	* Value will always be an array if the field is valid.
	*/
	if (value.length < options.min) field.report(messages["array.minLength"], "array.minLength", field, options);
}, { toJSONSchema: (schema, options) => {
	schema.minItems = options.min;
} });
/**
* Enforce a maximum length on an array field.
*
* Validates that an array contains at most the specified number of elements.
*
* @example
* vine.array(vine.string()).maxLength(10)
*/
const maxLengthRule$2 = createRule(function maxLength(value, options, field) {
	/**
	* Value will always be an array if the field is valid.
	*/
	if (value.length > options.max) field.report(messages["array.maxLength"], "array.maxLength", field, options);
}, { toJSONSchema: (schema, options) => {
	schema.maxItems = options.max;
} });
/**
* Enforce a fixed length on an array field.
*
* Validates that an array contains exactly the specified number of elements.
*
* @example
* vine.array(vine.string()).fixedLength(5)
*/
const fixedLengthRule$2 = createRule(function fixedLength(value, options, field) {
	/**
	* Value will always be an array if the field is valid.
	*/
	if (value.length !== options.size) field.report(messages["array.fixedLength"], "array.fixedLength", field, options);
}, { toJSONSchema: (schema, options) => {
	schema.minItems = options.size;
	schema.maxItems = options.size;
} });
/**
* Ensure the array is not empty.
*
* Validates that an array contains at least one element.
*
* @example
* vine.array(vine.string()).notEmpty()
*/
const notEmptyRule = createRule(function notEmpty(value, _, field) {
	/**
	* Value will always be an array if the field is valid.
	*/
	if (value.length <= 0) field.report(messages.notEmpty, "notEmpty", field);
}, { toJSONSchema: (schema) => {
	schema.minItems = 1;
} });
/**
* Ensure array elements are distinct/unique.
*
* For primitive arrays, validates that all elements are unique.
* For object arrays, validates uniqueness based on specified field(s).
*
* @example
* // Validate primitive array uniqueness
* vine.array(vine.string()).distinct()
*
* @example
* // Validate object array uniqueness by field
* vine.array(vine.object({ id: vine.number() })).distinct('id')
*
* @example
* // Validate object array uniqueness by multiple fields
* vine.array(vine.object({
*   name: vine.string(),
*   email: vine.string()
* })).distinct(['name', 'email'])
*/
const distinctRule = createRule(function distinct(value, options, field) {
	/**
	* Value will always be an array if the field is valid.
	*/
	if (!helpers.isDistinct(value, options.fields)) field.report(messages.distinct, "distinct", field, options);
}, { toJSONSchema: (schema) => {
	schema.uniqueItems = true;
} });
/**
* Removes empty strings, null and undefined values from the array.
*
* This rule mutates the array by filtering out falsy values and empty strings.
* It does not fail validation but transforms the input by removing unwanted values.
*
* @example
* vine.array(vine.string()).compact()
* // Input: ['a', '', null, 'b', undefined]
* // Output: ['a', 'b']
*/
const compactRule = createRule(function compact(value, _, field) {
	/**
	* Skip if the field is not valid.
	*/
	if (!field.isValid) return;
	field.mutate(value.filter((item) => helpers.exists(item) && item !== ""), field);
});
//#endregion
//#region src/schema/array/main.ts
/**
* VineArray represents an array schema type in the validation pipeline.
* It validates arrays and their elements using a nested schema, with support
* for length constraints, uniqueness checks, and element filtering.
*
* @template Schema - The schema type for validating array elements
*
* @example
* const schema = vine.array(vine.string().email())
*   .minLength(1)
*   .maxLength(10)
*   .distinct()
*
* const result = await vine.validate({
*   schema,
*   data: ['user1@example.com', 'user2@example.com']
* })
*/
var VineArray = class VineArray extends BaseType {
	/**
	* Static collection of all available validation rules for arrays
	*/
	static rules = {
		compact: compactRule,
		notEmpty: notEmptyRule,
		distinct: distinctRule,
		minLength: minLengthRule$2,
		maxLength: maxLengthRule$2,
		fixedLength: fixedLengthRule$2
	};
	/**
	* The schema used to validate each element in the array
	*/
	#schema;
	/**
	* Unique name identifier for union type resolution
	*/
	[UNIQUE_NAME] = "vine.array";
	/**
	* Type checker function to determine if a value is an array.
	* Required for "unionOfTypes" functionality.
	*
	* @param value - The value to check
	* @returns True if the value is an array
	*/
	[IS_OF_TYPE] = (value) => {
		return Array.isArray(value);
	};
	/**
	* Creates a new VineArray instance with element schema and optional configuration.
	*
	* @param schema - The schema to validate each array element
	* @param options - Field options like bail mode and nullability
	* @param validations - Initial set of validations to apply
	*/
	constructor(schema, options, validations) {
		super(options, validations);
		this.#schema = schema;
	}
	/**
	* Enforce a minimum length on an array field.
	*
	* @param expectedLength - The minimum required number of elements
	* @returns This array schema instance for method chaining
	*/
	minLength(expectedLength) {
		return this.use(minLengthRule$2({ min: expectedLength }));
	}
	/**
	* Enforce a maximum length on an array field.
	*
	* @param expectedLength - The maximum allowed number of elements
	* @returns This array schema instance for method chaining
	*/
	maxLength(expectedLength) {
		return this.use(maxLengthRule$2({ max: expectedLength }));
	}
	/**
	* Enforce a fixed length on an array field.
	*
	* @param expectedLength - The exact required number of elements
	* @returns This array schema instance for method chaining
	*/
	fixedLength(expectedLength) {
		return this.use(fixedLengthRule$2({ size: expectedLength }));
	}
	/**
	* Ensure the array is not empty.
	*
	* @returns This array schema instance for method chaining
	*/
	notEmpty() {
		return this.use(notEmptyRule());
	}
	/**
	* Ensure array elements are distinct/unique.
	*
	* @param fields - Optional field names to check for uniqueness in object arrays
	* @returns This array schema instance for method chaining
	*/
	distinct(fields) {
		return this.use(distinctRule({ fields }));
	}
	/**
	* Removes empty strings, null and undefined values from the array.
	*
	* @returns This array schema instance for method chaining
	*/
	compact() {
		return this.use(compactRule());
	}
	/**
	* Clones the VineArray schema type. The applied options
	* and validations are copied to the new instance.
	*
	* @returns A cloned instance of this VineArray schema
	*/
	clone() {
		return new VineArray(this.#schema.clone(), this.cloneOptions(), this.cloneValidations());
	}
	/**
	* Transforms into JSONSchema.
	*/
	toJSONSchema() {
		const schema = {
			type: "array",
			items: this.#schema.toJSONSchema?.() ?? {}
		};
		for (const validation of this.validations) {
			if (!validation.rule.toJSONSchema) continue;
			validation.rule.toJSONSchema(schema, validation.options);
		}
		return schema;
	}
	/**
	* Compiles to array data type for the validation compiler.
	*
	* @param propertyName - Name of the property being compiled
	* @param refs - Reference store for the compiler
	* @param options - Parser options
	* @returns Compiled array node for validation
	*/
	[PARSE](propertyName, refs, options) {
		return {
			type: "array",
			fieldName: propertyName,
			propertyName: options.toCamelCase ? camelcase(propertyName) : propertyName,
			bail: this.options.bail,
			allowNull: this.options.allowNull,
			isOptional: this.options.isOptional,
			each: this.#schema[PARSE]("*", refs, options),
			parseFnId: this.options.parse ? refs.trackParser(this.options.parse) : void 0,
			validations: this.compileValidations(refs)
		};
	}
};
//#endregion
//#region src/schema/object/main.ts
/**
* Converts schema properties to camelCase during validation.
* This is a wrapper around VineObject that automatically converts
* property names from snake_case to camelCase in the output.
*
* @template Schema - The underlying VineObject schema type
*
* @example
* const schema = vine.object({
*   first_name: vine.string(),
*   last_name: vine.string()
* }).camelCase()
*
* // Output will have: { firstName: string, lastName: string }
*/
var VineCamelCaseObject = class VineCamelCaseObject extends BaseType {
	/**
	* Reference to the underlying object schema
	*/
	#schema;
	/**
	* Unique name identifier for union type resolution
	*/
	[UNIQUE_NAME] = "types.object";
	/**
	* Type checker function to determine if a value is an object.
	* Required for "unionOfTypes" functionality.
	*
	* @param value - The value to check
	* @returns True if the value is a non-null object and not an array
	*/
	[IS_OF_TYPE] = (value) => {
		return value !== null && typeof value === "object" && !Array.isArray(value);
	};
	/**
	* Creates a new VineCamelCaseObject instance wrapping the given schema.
	*
	* @param schema - The VineObject schema to wrap with camelCase conversion
	*/
	constructor(schema) {
		super();
		this.#schema = schema;
	}
	/**
	* Clone object with camelCase conversion preserved.
	*
	* @returns A cloned instance of this VineCamelCaseObject schema
	*/
	clone() {
		return new VineCamelCaseObject(this.#schema.clone());
	}
	/**
	* Converts the object schema to JSON Schema format.
	*
	* @returns JSON Schema representation of this object
	*/
	toJSONSchema() {
		return this.#schema.toJSONSchema();
	}
	/**
	* Compiles the schema type to a compiler node with camelCase enabled.
	*
	* @param propertyName - Name of the property being compiled
	* @param refs - Reference store for the compiler
	* @param options - Parser options
	* @returns Compiled object node with camelCase conversion
	*/
	[PARSE](propertyName, refs, options) {
		options.toCamelCase = true;
		return this.#schema[PARSE](propertyName, refs, options);
	}
};
/**
* VineObject represents an object value in the validation schema.
* It validates objects with predefined properties, supports conditional
* groups, and provides control over unknown properties.
*
* @template Properties - Record of property names to their schema types
* @template Input - The expected input type for this object
* @template Output - The output type after validation and transformation
* @template CamelCaseOutput - The output type with camelCase property names
*
* @example
* const schema = vine.object({
*   name: vine.string(),
*   email: vine.string().email(),
*   age: vine.number().min(0)
* })
*
* const result = await vine.validate({
*   schema,
*   data: { name: 'John', email: 'john@example.com', age: 30 }
* })
*/
var VineObject = class VineObject extends BaseType {
	/**
	* Object properties mapping property names to their validation schemas
	*/
	#properties;
	/**
	* Object groups to merge based on conditionals.
	* These allow adding properties dynamically based on conditions.
	*/
	#groups = [];
	/**
	* Whether or not to allow unknown properties that are not defined
	* in the schema. When false, unknown properties cause validation errors.
	*/
	#allowUnknownProperties = false;
	/**
	* Unique name identifier for union type resolution
	*/
	[UNIQUE_NAME] = "vine.object";
	/**
	* Type checker function to determine if a value is an object.
	* Required for "unionOfTypes" functionality.
	*
	* @param value - The value to check
	* @returns True if the value is a non-null object and not an array
	*/
	[IS_OF_TYPE] = (value) => {
		return value !== null && typeof value === "object" && !Array.isArray(value);
	};
	/**
	* Creates a new VineObject instance with property schemas and optional configuration.
	*
	* @param properties - Record of property names to their validation schemas
	* @param options - Field options like bail mode and nullability
	* @param validations - Initial set of validations to apply
	* @throws Error if properties is not provided
	*/
	constructor(properties, options, validations) {
		if (!properties) throw new Error("Missing properties for \"vine.object\". Use an empty object if you do not want to validate any specific fields");
		super(options, validations);
		this.#properties = properties;
	}
	/**
	* Returns a cloned copy of all object properties with their validation schemas.
	* Note: Object groups are not included to keep implementations simple.
	*
	* @returns Cloned properties record
	*
	* @example
	* const properties = schema.getProperties()
	*/
	getProperties() {
		return Object.keys(this.#properties).reduce((result, key) => {
			result[key] = this.#properties[key].clone();
			return result;
		}, {});
	}
	/**
	* Returns a cloned subset of object properties containing only the specified keys.
	*
	* @param keys - Array of property keys to include
	* @returns Picked properties record
	*
	* @example
	* const userSchema = vine.object({
	*   name: vine.string(),
	*   email: vine.string().email(),
	*   password: vine.string()
	* })
	*
	* const publicFields = userSchema.pick(['name', 'email'])
	*/
	pick(keys) {
		const result = {};
		for (const key of keys) result[key] = this.#properties[key].clone();
		return result;
	}
	/**
	* Returns a cloned copy of object properties excluding the specified keys.
	*
	* @param keys - Array of property keys to exclude
	* @returns Omitted properties record
	*
	* @example
	* const userSchema = vine.object({
	*   name: vine.string(),
	*   email: vine.string().email(),
	*   password: vine.string()
	* })
	*
	* const withoutPassword = userSchema.omit(['password'])
	*/
	omit(keys) {
		const result = {};
		for (const key of Object.keys(this.#properties)) if (!keys.includes(key)) result[key] = this.#properties[key].clone();
		return result;
	}
	/**
	* 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.
	*
	* @returns This object schema with unknown properties allowed
	*
	* @example
	* const schema = vine.object({
	*   name: vine.string()
	* }).allowUnknownProperties()
	*
	* // Now { name: 'John', extra: 'value' } will pass validation
	*/
	allowUnknownProperties() {
		this.#allowUnknownProperties = true;
		return this;
	}
	/**
	* Merges conditional property groups into the object schema. Groups allow
	* adding properties dynamically based on runtime conditions.
	*
	* @param group - The conditional group to merge
	* @returns This object schema with the group merged
	*
	* @example
	* const schema = vine.object({
	*   type: vine.string()
	* }).merge(
	*   vine.group([
	*     vine.group.if('type', 'user', { name: vine.string() }),
	*     vine.group.if('type', 'admin', { permissions: vine.array(vine.string()) })
	*   ])
	* )
	*/
	merge(group) {
		this.#groups.push(group);
		return this;
	}
	/**
	* Clones the VineObject schema including all properties, validations, groups, and options.
	*
	* @returns A cloned instance of this VineObject schema
	*/
	clone() {
		const cloned = new VineObject(this.getProperties(), this.cloneOptions(), this.cloneValidations());
		this.#groups.forEach((group) => cloned.merge(group));
		if (this.#allowUnknownProperties) cloned.allowUnknownProperties();
		return cloned;
	}
	/**
	* Converts object property names to camelCase in the validation output.
	* Useful when accepting snake_case input but wanting camelCase output.
	*
	* @returns A VineCamelCaseObject wrapper for this schema
	*
	* @example
	* const schema = vine.object({
	*   first_name: vine.string(),
	*   last_name: vine.string()
	* }).toCamelCase()
	*
	* // Output: { firstName: string, lastName: string }
	*/
	toCamelCase() {
		return new VineCamelCaseObject(this);
	}
	/**
	* Converts the object schema to JSON Schema format.
	*
	* @returns JSON Schema representation of this object
	*/
	toJSONSchema() {
		const properties = {};
		const required = [];
		for (const [key, property] of Object.entries(this.getProperties())) {
			if (!property.toJSONSchema) continue;
			properties[key] = property.toJSONSchema();
			if (property.isOptional !== true && property.allowNull !== true) required.push(key);
		}
		const schema = {
			type: "object",
			properties,
			required,
			additionalProperties: this.#allowUnknownProperties
		};
		for (const validation of this.validations) {
			if (!validation.rule.toJSONSchema) continue;
			validation.rule.toJSONSchema(schema, validation.options);
		}
		if (this.#groups.length > 0) return { anyOf: [...this.#groups.map((group) => group.toJSONSchema()), schema] };
		return schema;
	}
	/**
	* 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.
	*
	* @param keys - Optional array of property keys to make optional. If omitted, all properties become optional.
	* @returns A new VineObject schema with optional properties
	*
	* @example
	* // Make all properties optional
	* const updateSchema = createSchema.partial()
	*
	* @example
	* // Make only specific properties optional
	* const userSchema = vine.object({
	*   name: vine.string(),
	*   email: vine.string().email(),
	*   age: vine.number()
	* })
	*
	* const updateUserSchema = userSchema.partial(['name', 'age'])
	* // email remains required, name and age become optional
	*/
	partial(keys) {
		/**
		* Groups cannot be optional standalone, hence they cannot be marked
		* as optional when merged inside an object. Same is true for
		* unknownProperties.
		*/
		if (this.#groups.length > 0 || this.#allowUnknownProperties) throw new Error("toOptional cannot be used on schemas that have groups or allowUnknownProperties enabled");
		const properties = {};
		for (const key of Object.keys(this.#properties)) {
			let field = this.#properties[key].clone();
			if ((!keys || keys.includes(key)) && "optional" in field && typeof field.optional === "function") field = field.optional();
			properties[key] = field;
		}
		return new VineObject(properties, this.cloneOptions(), this.cloneValidations());
	}
	/**
	* Compiles the schema type to a compiler node for validation.
	*
	* @param propertyName - Name of the property being compiled
	* @param refs - Reference store for the compiler
	* @param options - Parser options
	* @returns Compiled object node for validation
	*/
	[PARSE](propertyName, refs, options) {
		return {
			type: "object",
			fieldName: propertyName,
			propertyName: options.toCamelCase ? camelcase(propertyName) : propertyName,
			bail: this.options.bail,
			allowNull: this.options.allowNull,
			isOptional: this.options.isOptional,
			parseFnId: this.options.parse ? refs.trackParser(this.options.parse) : void 0,
			allowUnknownProperties: this.#allowUnknownProperties,
			validations: this.compileValidations(refs),
			properties: Object.keys(this.#properties).map((property) => {
				return this.#properties[property][PARSE](property, refs, options);
			}),
			groups: this.#groups.map((group) => {
				return group[PARSE](refs, options);
			})
		};
	}
};
//#endregion
//#region src/schema/record/rules.ts
/**
* Enforce a minimum number of properties on a record field.
*
* Validates that a record (object) contains at least the specified number of key-value pairs.
*
* @example
* vine.record(vine.string()).minLength(2)
*/
const minLengthRule$1 = createRule(function minLength(value, options, field) {
	/**
	* Value will always be an object if the field is valid.
	*/
	if (Object.keys(value).length < options.min) field.report(messages["record.minLength"], "record.minLength", field, options);
}, { toJSONSchema: (schema, options) => {
	schema.minProperties = options.min;
} });
/**
* Enforce a maximum number of properties on a record field.
*
* Validates that a record (object) contains at most the specified number of key-value pairs.
*
* @example
* vine.record(vine.string()).maxLength(10)
*/
const maxLengthRule$1 = createRule(function maxLength(value, options, field) {
	/**
	* Value will always be an object if the field is valid.
	*/
	if (Object.keys(value).length > options.max) field.report(messages["record.maxLength"], "record.maxLength", field, options);
}, { toJSONSchema: (schema, options) => {
	schema.maxProperties = options.max;
} });
/**
* Enforce an exact number of properties on a record field.
*
* Validates that a record (object) contains exactly the specified number of key-value pairs.
*
* @example
* vine.record(vine.string()).fixedLength(5)
*/
const fixedLengthRule$1 = createRule(function fixedLength(value, options, field) {
	/**
	* Value will always be an object if the field is valid.
	*/
	if (Object.keys(value).length !== options.size) field.report(messages["record.fixedLength"], "record.fixedLength", field, options);
}, { toJSONSchema: (schema, options) => {
	schema.minProperties = options.size;
	schema.maxProperties = options.size;
} });
/**
* Register a custom callback to validate the record's keys.
*
* Allows implementing custom key validation logic, such as checking key patterns,
* enforcing naming conventions, or validating key existence.
*
* @example
* vine.record(vine.string()).validateKeys((keys, field) => {
*   // Ensure all keys are lowercase
*   if (!keys.every(key => key === key.toLowerCase())) {
*     field.report('All keys must be lowercase', 'invalidKeys', field)
*   }
* })
*
* @example
* // Validate that certain keys exist
* vine.record(vine.string()).validateKeys((keys, field) => {
*   if (!keys.includes('id')) {
*     field.report('Record must contain an "id" key', 'missingId', field)
*   }
* })
*/
const validateKeysRule = createRule(function validateKeys(value, callback, field) {
	callback(Object.keys(value), field);
});
//#endregion
//#region src/schema/record/main.ts
/**
* 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.
*
* @template Schema - The schema type for validating all record values
*
* @example
* const schema = vine.record(vine.number())
*
* const result = await vine.validate({
*   schema,
*   data: { a: 1, b: 2, c: 3 }
* })
*
* @example
* // Record with complex value types
* const schema = vine.record(
*   vine.object({
*     name: vine.string(),
*     age: vine.number()
*   })
* )
*/
var VineRecord = class VineRecord extends BaseType {
	/**
	* Static collection of all available validation rules for records
	*/
	static rules = {
		maxLength: maxLengthRule$1,
		minLength: minLengthRule$1,
		fixedLength: fixedLengthRule$1,
		validateKeys: validateKeysRule
	};
	/**
	* The schema used to validate each value in the record
	*/
	#schema;
	/**
	* Unique name identifier for union type resolution
	*/
	[UNIQUE_NAME] = "vine.object";
	/**
	* Type checker function to determine if a value is an object.
	* Required for "unionOfTypes" functionality.
	*
	* @param value - The value to check
	* @returns True if the value is a non-null object and not an array
	*/
	[IS_OF_TYPE] = (value) => {
		return value !== null && typeof value === "object" && !Array.isArray(value);
	};
	/**
	* Creates a new VineRecord instance with value schema and optional configuration.
	*
	* @param schema - The schema to validate each record value
	* @param options - Field options like bail mode and nullability
	* @param validations - Initial set of validations to apply
	*/
	constructor(schema, options, validations) {
		super(options, validations);
		this.#schema = schema;
	}
	/**
	* Enforce a minimum number of properties on the record.
	*
	* @param expectedLength - The minimum required number of key-value pairs
	* @returns This record schema instance for method chaining
	*/
	minLength(expectedLength) {
		return this.use(minLengthRule$1({ min: expectedLength }));
	}
	/**
	* Enforce a maximum number of properties on the record.
	*
	* @param expectedLength - The maximum allowed number of key-value pairs
	* @returns This record schema instance for method chaining
	*/
	maxLength(expectedLength) {
		return this.use(maxLengthRule$1({ max: expectedLength }));
	}
	/**
	* Enforce an exact number of properties on the record.
	*
	* @param expectedLength - The exact required number of key-value pairs
	* @returns This record schema instance for method chaining
	*/
	fixedLength(expectedLength) {
		return this.use(fixedLengthRule$1({ size: expectedLength }));
	}
	/**
	* Register a custom callback to validate the record's keys.
	* Useful for enforcing key naming patterns or checking key existence.
	*
	* @param args - Arguments to pass to the validateKeys rule
	* @returns This record schema instance for method chaining
	*
	* @example
	* vine.record(vine.string()).validateKeys((keys, field) => {
	*   if (!keys.every(key => /^[a-z_]+$/.test(key))) {
	*     field.report('Keys must be lowercase with underscores', 'invalidKeys', field)
	*   }
	* })
	*/
	validateKeys(...args) {
		return this.use(validateKeysRule(...args));
	}
	/**
	* Clones the VineRecord schema including the value schema, options, and validations.
	*
	* @returns A cloned instance of this VineRecord schema
	*/
	clone() {
		return new VineRecord(this.#schema.clone(), this.cloneOptions(), this.cloneValidations());
	}
	/**
	* Converts the record schema to JSON Schema format.
	*
	* @returns JSON Schema representation of this record
	*/
	toJSONSchema() {
		const schema = {
			type: "object",
			additionalProperties: {}
		};
		schema.additionalProperties = this.#schema.toJSONSchema?.() ?? {};
		for (const validation of this.validations) {
			if (!validation.rule.toJSONSchema) continue;
			validation.rule.toJSONSchema(schema, validation.options);
		}
		return schema;
	}
	/**
	* Compiles the record schema to a compiler node for validation.
	*
	* @param propertyName - Name of the property being compiled
	* @param refs - Reference store for the compiler
	* @param options - Parser options
	* @returns Compiled record node for validation
	*/
	[PARSE](propertyName, refs, options) {
		return {
			type: "record",
			fieldName: propertyName,
			propertyName: options.toCamelCase ? camelcase(propertyName) : propertyName,
			bail: this.options.bail,
			allowNull: this.options.allowNull,
			isOptional: this.options.isOptional,
			each: this.#schema[PARSE]("*", refs, options),
			parseFnId: this.options.parse ? refs.trackParser(this.options.parse) : void 0,
			validations: this.compileValidations(refs)
		};
	}
};
//#endregion
//#region src/schema/string/rules.ts
/**
* Validates the value to be a string.
* Reports an error if the value is not of type string.
*
* @example
* vine.string()
*/
const stringRule = createRule(function string(value, _, field) {
	if (!field.isDefined) return false;
	if (typeof value === "string") return true;
	field.report(messages.string, "string", field);
	return false;
}, { toJSONSchema: (schema) => {
	schema.type = "string";
} });
/**
* Validates the value to be a valid email address.
* Supports various email validation options including domain-specific rules.
*
* @example
* vine.string().email()
* vine.string().email({ allow_ip_domain: true })
*/
const emailRule = createRule(function email(value, options, field) {
	if (!helpers.isEmail(value, options)) field.report(messages.email, "email", field);
}, { toJSONSchema: (schema) => {
	schema.format = "email";
} });
/**
* Validates the value to be a valid mobile phone number for specified locales.
* Supports locale-specific mobile number formats and strict mode validation.
*
* @example
* vine.string().mobile()
* vine.string().mobile({ locale: ['en-US', 'en-GB'] })
* vine.string().mobile({ locale: ['en-US'], strictMode: true })
*/
const mobileRule = createRule(function mobile(value, options, field) {
	const normalizedOptions = options && typeof options === "function" ? options(field) : options;
	const locales = normalizedOptions?.locale || "any";
	if (!helpers.isMobilePhone(value, locales, normalizedOptions)) field.report(messages.mobile, "mobile", field);
});
/**
* Validates the value to be a valid IP address (IPv4 or IPv6).
* Optionally restricts to a specific IP version.
*
* @example
* vine.string().ipAddress()
* vine.string().ipAddress({ version: 4 })
* vine.string().ipAddress({ version: 6 })
*/
const ipAddressRule = createRule(function ipAddress(value, options, field) {
	if (!helpers.isIP(value, options?.version)) field.report(messages.ipAddress, "ipAddress", field);
}, { toJSONSchema: (schema, options) => {
	schema.format = options?.version === 6 ? "ipv6" : "ipv4";
} });
/**
* Validates the value against a custom regular expression pattern.
* The value must match the provided regular expression.
*
* @example
* vine.string().regex(/^[A-Z]{3}\d{3}$/)
* vine.string().regex(/^\d{4}-\d{2}-\d{2}$/)
*/
const regexRule = createRule(function regex(value, expression, field) {
	if (!expression.test(value)) field.report(messages.regex, "regex", field);
}, { toJSONSchema: (schema, options) => {
	schema.pattern = options.source;
} });
/**
* Validates the value to be a valid hexadecimal color code.
* Accepts formats like #FFF, #FFFFFF, or #FFFFFFFF.
*
* @example
* vine.string().hexCode()
*/
const hexCodeRule = createRule(function hexCode(value, _, field) {
	if (!helpers.isHexColor(value)) field.report(messages.hexCode, "hexCode", field);
}, { toJSONSchema: (schema) => {
	schema.pattern = "^#?([0-9a-f]{6}|[0-9a-f]{3}|[0-9a-f]{8})$";
} });
/**
* Validates the value to be a valid URL.
* Supports various URL validation options including protocol requirements.
*
* @example
* vine.string().url()
* vine.string().url({ require_protocol: true })
* vine.string().url({ protocols: ['https'] })
*/
const urlRule = createRule(function url(value, options, field) {
	if (!helpers.isURL(value, options)) field.report(messages.url, "url", field);
}, { toJSONSchema: (schema) => {
	schema.format = "uri";
} });
/**
* Validates the value to be an active URL by making an HTTP request.
* Checks if the URL is reachable and returns a successful response.
*
* @example
* vine.string().activeUrl()
*/
const activeUrlRule = createRule(async function activeUrl(value, _, field) {
	if (!await helpers.isActiveURL(value)) field.report(messages.activeUrl, "activeUrl", field);
});
/**
* Validates the value to contain only alphabetic characters.
* Supports options to allow spaces, dashes, and underscores.
*
* @example
* vine.string().alpha()
* vine.string().alpha({ allowSpaces: true })
* vine.string().alpha({ allowDashes: true, allowUnderscores: true })
*/
const alphaRule = createRule(function alpha(value, options, field) {
	let characterSet = "a-zA-Z";
	if (options) {
		if (options.allowSpaces) characterSet += "\\s";
		if (options.allowDashes) characterSet += "-";
		if (options.allowUnderscores) characterSet += "_";
	}
	if (!new RegExp(`^[${characterSet}]+$`).test(value)) field.report(messages.alpha, "alpha", field);
}, { toJSONSchema: (schema, options) => {
	let characterSet = "a-zA-Z";
	if (options) {
		if (options.allowSpaces) characterSet += "\\s";
		if (options.allowDashes) characterSet += "-";
		if (options.allowUnderscores) characterSet += "_";
	}
	schema.pattern = `^[${characterSet}]+$`;
} });
/**
* Validates the value to contain only alphanumeric characters (letters and numbers).
* Supports options to allow spaces, dashes, and underscores.
*
* @example
* vine.string().alphaNumeric()
* vine.string().alphaNumeric({ allowSpaces: true })
* vine.string().alphaNumeric({ allowDashes: true, allowUnderscores: true })
*/
const alphaNumericRule = createRule(function alphaNumeric(value, options, field) {
	let characterSet = "a-zA-Z0-9";
	if (options) {
		if (options.allowSpaces) characterSet += "\\s";
		if (options.allowDashes) characterSet += "-";
		if (options.allowUnderscores) characterSet += "_";
	}
	if (!new RegExp(`^[${characterSet}]+$`).test(value)) field.report(messages.alphaNumeric, "alphaNumeric", field);
}, { toJSONSchema: (schema, options) => {
	let characterSet = "a-zA-Z0-9";
	if (options) {
		if (options.allowSpaces) characterSet += "\\s";
		if (options.allowDashes) characterSet += "-";
		if (options.allowUnderscores) characterSet += "_";
	}
	schema.pattern = `^[${characterSet}]+$`;
} });
/**
* Enforces a minimum length on a string field.
* The string must have at least the specified number of characters.
*
* @example
* vine.string().minLength(5)
*/
const minLengthRule = createRule(function minLength(value, options, field) {
	if (value.length < options.min) field.report(messages.minLength, "minLength", field, options);
}, { toJSONSchema: (schema, options) => {
	schema.minLength = options.min;
} });
/**
* Enforces a maximum length on a string field.
* The string must not exceed the specified number of characters.
*
* @example
* vine.string().maxLength(100)
*/
const maxLengthRule = createRule(function maxLength(value, options, field) {
	if (value.length > options.max) field.report(messages.maxLength, "maxLength", field, options);
}, { toJSONSchema: (schema, options) => {
	schema.maxLength = options.max;
} });
/**
* Enforces a fixed length on a string field.
* The string must have exactly the specified number of characters.
*
* @example
* vine.string().fixedLength(10)
*/
const fixedLengthRule = createRule(function fixedLength(value, options, field) {
	if (value.length !== options.size) field.report(messages.fixedLength, "fixedLength", field, options);
}, { toJSONSchema: (schema, options) => {
	schema.minLength = options.size;
	schema.maxLength = options.size;
} });
/**
* Ensures the value ends with the specified substring.
* The comparison is case-sensitive.
*
* @example
* vine.string().endsWith('.com')
* vine.string().endsWith('_test')
*/
const endsWithRule = createRule(function endsWith(value, options, field) {
	if (!value.endsWith(options.substring)) field.report(messages.endsWith, "endsWith", field, options);
});
/**
* Ensures the value starts with the specified substring.
* The comparison is case-sensitive.
*
* @example
* vine.string().startsWith('https://')
* vine.string().startsWith('prefix_')
*/
const startsWithRule = createRule(function startsWith(value, options, field) {
	if (!value.startsWith(options.substring)) field.report(messages.startsWith, "startsWith", field, options);
});
/**
* Ensures the field's value under validation is the same as the other field's value.
* Useful for confirmation fields like password verification.
*
* @example
* vine.string().sameAs('password')
* vine.string().sameAs('email')
*/
const sameAsRule = createRule(function sameAs(value, options, field) {
	/**
	* Performing validation and reporting error
	*/
	if (helpers.getNestedValue(options.otherField, field) !== value) {
		field.report(messages.sameAs, "sameAs", field, options);
		return;
	}
});
/**
* Ensures the field's value under validation is different from another field's value.
* Useful for ensuring new values differ from old ones (e.g., new password vs old password).
*
* @example
* vine.string().notSameAs('oldPassword')
* vine.string().notSameAs('previousEmail')
*/
const notSameAsRule = createRule(function notSameAs(value, options, field) {
	/**
	* Performing validation and reporting error
	*/
	if (helpers.getNestedValue(options.otherField, field) === value) {
		field.report(messages.notSameAs, "notSameAs", field, options);
		return;
	}
});
/**
* Ensures the field under validation is confirmed by having another field with the same name
* (with "_confirmation" suffix by default). The values of both fields must match.
*
* @example
* vine.string().confirmed()
* vine.string().confirmed({ as: 'passwordConfirm' })
*/
const confirmedRule = createRule(function confirmed(value, options, field) {
	const normalizedOptions = options ?? {};
	const otherField = normalizedOptions.as ?? normalizedOptions.confirmationField ?? `${field.name}_confirmation`;
	const input = field.parent[otherField];
	/**
	* Performing validation and reporting error
	*/
	if (input !== value) {
		field.report(messages.confirmed, "confirmed", {
			...field,
			name: otherField,
			wildCardPath: `${field.wildCardPath.replace(String(field.name), otherField)}`,
			isDefined: true,
			isValid: false,
			value: input,
			getFieldPath() {
				return `${field.getFieldPath().replace(String(field.name), otherField)}`;
			}
		}, {
			otherField,
			originalField: field.name
		});
		return;
	}
});
/**
* Ensures the field's value under validation is one of the pre-defined choices.
* Accepts a static array of choices or a function that returns choices dynamically.
*
* @example
* vine.string().in(['red', 'green', 'blue'])
* vine.string().in((field) => getUserRoles(field.meta.userId))
*/
const inRule$1 = createRule(function inList(value, options, field) {
	/**
	* Performing validation and reporting error
	*/
	if (!(typeof options.choices === "function" ? options.choices(field) : options.choices).includes(value)) {
		field.report(messages.in, "in", field, options);
		return;
	}
});
/**
* Ensures the field's value under validation is not in the pre-defined list.
* Accepts a static array or a function that returns disallowed values dynamically.
*
* @example
* vine.string().notIn(['admin', 'root', 'system'])
* vine.string().notIn((field) => getBlacklistedUsernames())
*/
const notInRule = createRule(function notIn(value, options, field) {
	/**
	* Performing validation and reporting error
	*/
	if ((typeof options.list === "function" ? options.list(field) : options.list).includes(value)) {
		field.report(messages.notIn, "notIn", field, options);
		return;
	}
});
/**
* Validates the value to be a valid credit card number.
* Optionally restricts validation to specific card providers.
*
* @example
* vine.string().creditCard()
* vine.string().creditCard({ provider: ['visa', 'mastercard'] })
* vine.string().creditCard({ provider: ['amex', 'discover'] })
*/
const creditCardRule = createRule(function creditCard(value, options, field) {
	const providers = options ? typeof options === "function" ? options(field)?.provider || [] : options.provider : [];
	if (!providers.length) {
		if (!helpers.isCreditCard(value)) field.report(messages.creditCard, "creditCard", field, { providersList: "credit" });
	} else if (!providers.find((provider) => helpers.isCreditCard(value, { provider }))) field.report(messages.creditCard, "creditCard", field, {
		providers,
		providersList: providers.join("/")
	});
});
/**
* Validates the value to be a valid passport number for specified countries.
* Requires country codes to determine the expected passport format.
*
* @example
* vine.string().passport({ countryCode: ['US', 'GB', 'CA'] })
* vine.string().passport({ countryCode: ['FR', 'DE'] })
*/
const passportRule = createRule(function passport(value, options, field) {
	const countryCodes = typeof options === "function" ? options(field).countryCode : options.countryCode;
	if (!countryCodes.find((countryCode) => helpers.isPassportNumber(value, countryCode))) field.report(messages.passport, "passport", field, { countryCodes });
});
/**
* Validates the value to be a valid VAT (Value Added Tax) number for specified countries.
* Requires country codes to determine the expected VAT format.
*
* @example
* vine.string().vat({ countryCode: ['FR', 'CH', 'VE'] })
* vine.string().vat({ countryCode: ['GB', 'DE'] })
*/
const vatRule = createRule(function vat(value, options, field) {
	const countryCodes = typeof options === "function" ? options(field).countryCode : options.countryCode;
	if (!countryCodes.find((countryCode) => helpers.isVAT(value, countryCode))) field.report(messages.vat, "vat", field, { countryCodes });
});
/**
* Validates the value to be a valid postal code.
* Optionally restricts validation to specific country codes.
*
* @example
* vine.string().postalCode()
* vine.string().postalCode({ countryCode: ['US', 'GB', 'CA'] })
* vine.string().postalCode({ countryCode: ['FR', 'DE'] })
*/
const postalCodeRule = createRule(function postalCode(value, options, field) {
	const countryCodes = options ? typeof options === "function" ? options(field)?.countryCode || [] : options.countryCode : [];
	if (!countryCodes.length) {
		if (!helpers.isPostalCode(value, "any")) field.report(messages.postalCode, "postalCode", field);
	} else if (!countryCodes.find((countryCode) => helpers.isPostalCode(value, countryCode))) field.report(messages.postalCode, "postalCode", field, { countryCodes });
});
/**
* Validates the value to be a valid UUID (Universally Unique Identifier).
* Optionally restricts validation to specific UUID versions.
*
* @example
* vine.string().uuid()
* vine.string().uuid({ version: [4] })
* vine.string().uuid({ version: [1, 4, 5] })
*/
const uuidRule = createRule(function uuid(value, options, field) {
	if (!options || !options.version) {
		if (!helpers.isUUID(value)) field.report(messages.uuid, "uuid", field);
	} else if (!options.version.find((version) => helpers.isUUID(value, version))) field.report(messages.uuid, "uuid", field, options);
}, { toJSONSchema: (schema) => {
	schema.format = "uuid";
} });
/**
* Validates the value to be a valid ULID (Universally Unique Lexicographically Sortable Identifier).
* ULIDs are 26 characters long and sortable by time.
*
* @example
* vine.string().ulid()
*/
const ulidRule = createRule(function ulid(value, _, field) {
	if (!helpers.isULID(value)) field.report(messages.ulid, "ulid", field);
}, { toJSONSchema: (schema) => {
	schema.pattern = "^[0-7][0-9A-HJKMNP-TV-Z]{25}$";
} });
/**
* Validates the value contains only ASCII characters (codes 0-127).
* Rejects any characters outside the standard ASCII range.
*
* @example
* vine.string().ascii()
*/
const asciiRule = createRule(function ascii(value, _, field) {
	if (!helpers.isAscii(value)) field.report(messages.ascii, "ascii", field);
});
/**
* Validates the value to be a valid IBAN (International Bank Account Number).
* Validates format, check digits, and country-specific patterns.
*
* @example
* vine.string().iban()
*/
const ibanRule = createRule(function iban(value, _, field) {
	if (!helpers.isIBAN(value)) field.report(messages.iban, "iban", field);
});
/**
* Validates the value to be a valid JWT (JSON Web Token).
* Validates the token structure but does not verify the signature.
*
* @example
* vine.string().jwt()
*/
const jwtRule = createRule(function jwt(value, _, field) {
	if (!helpers.isJWT(value)) field.report(messages.jwt, "jwt", field);
});
/**
* Ensures the value is a string containing valid latitude and longitude coordinates.
* Accepts format like "40.7128,-74.0060" (latitude,longitude).
*
* @example
* vine.string().coordinates()
*/
const coordinatesRule = createRule(function coordinates(value, _, field) {
	if (!helpers.isLatLong(value)) field.report(messages.coordinates, "coordinates", field);
});
/**
* Trims leading and trailing whitespace from the string value.
* Mutates the field value by removing whitespace characters.
*
* @example
* vine.string().trim()
*/
const trimRule = createRule(function trim(value, _, field) {
	if (!field.isValid) return;
	field.mutate(value.trim(), field);
});
/**
* Normalizes the email address by applying transformations.
* Supports options like lowercasing and removing dots from Gmail addresses.
*
* @example
* vine.string().email().normalizeEmail()
* vine.string().email().normalizeEmail({ gmail_remove_dots: true })
*/
const normalizeEmailRule = createRule(function normalizeEmail(value, options, field) {
	if (!field.isValid) return;
	field.mutate(normalizeEmailValue.default(value, options), field);
});
/**
* Converts the field value to UPPERCASE using locale-aware conversion.
* Mutates the field value to uppercase.
*
* @example
* vine.string().toUpperCase()
* vine.string().toUpperCase('tr-TR')
*/
const toUpperCaseRule = createRule(function toUpperCase(value, locales, field) {
	if (!field.isValid) return;
	field.mutate(value.toLocaleUpperCase(locales), field);
});
/**
* Converts the field value to lowercase using locale-aware conversion.
* Mutates the field value to lowercase.
*
* @example
* vine.string().toLowerCase()
* vine.string().toLowerCase('tr-TR')
*/
const toLowerCaseRule = createRule(function toLowerCase(value, locales, field) {
	if (!field.isValid) return;
	field.mutate(value.toLocaleLowerCase(locales), field);
});
/**
* Converts the field value to camelCase.
* Transforms strings like "hello_world" to "helloWorld".
*
* @example
* vine.string().toCamelCase()
*/
const toCamelCaseRule = createRule(function toCamelCase(value, _, field) {
	if (!field.isValid) return;
	field.mutate(camelcase(value), field);
});
/**
* Escapes HTML entities in the string to prevent XSS attacks.
* Converts characters like <, >, &, ", ' to their HTML entity equivalents.
*
* @example
* vine.string().escape()
*/
const escapeRule = createRule(function escape(value, _, field) {
	if (!field.isValid) return;
	field.mutate(escapeValue.default(value), field);
});
/**
* Normalizes a URL by applying standardization rules.
* Supports options like removing trailing slashes, sorting query parameters, and stripping default ports.
*
* @example
* vine.string().url().normalizeUrl()
* vine.string().url().normalizeUrl({ stripWWW: true })
* vine.string().url().normalizeUrl({ sortQueryParameters: true })
*/
const normalizeUrlRule = createRule(function normalizeUrlValue(value, options, field) {
	if (!field.isValid) return;
	field.mutate(normalizeUrl(value, options), field);
});
//#endregion
//#region src/schema/string/main.ts
/**
* 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
* const schema = vine.string()
*   .email()
*   .minLength(5)
*   .maxLength(100)
*
* const result = await vine.validate({
*   schema,
*   data: 'user@example.com'
* })
*/
var VineString = class VineString extends BaseLiteralType {
	/**
	* Static collection of all available validation rules for strings
	*/
	static rules = {
		in: inRule$1,
		jwt: jwtRule,
		url: urlRule,
		iban: ibanRule,
		uuid: uuidRule,
		ulid: ulidRule,
		trim: trimRule,
		email: emailRule,
		alpha: alphaRule,
		ascii: asciiRule,
		notIn: notInRule,
		regex: regexRule,
		escape: escapeRule,
		sameAs: sameAsRule,
		mobile: mobileRule,
		string: stringRule,
		hexCode: hexCodeRule,
		passport: passportRule,
		endsWith: endsWithRule,
		confirmed: confirmedRule,
		activeUrl: activeUrlRule,
		minLength: minLengthRule,
		notSameAs: notSameAsRule,
		maxLength: maxLengthRule,
		vat: vatRule,
		ipAddress: ipAddressRule,
		creditCard: creditCardRule,
		postalCode: postalCodeRule,
		startsWith: startsWithRule,
		toUpperCase: toUpperCaseRule,
		toLowerCase: toLowerCaseRule,
		toCamelCase: toCamelCaseRule,
		fixedLength: fixedLengthRule,
		coordinates: coordinatesRule,
		normalizeUrl: normalizeUrlRule,
		alphaNumeric: alphaNumericRule,
		normalizeEmail: normalizeEmailRule
	};
	/**
	* The subtype identifier for the literal schema field
	*/
	[SUBTYPE] = "string";
	/**
	* Unique name identifier for union type resolution
	*/
	[UNIQUE_NAME] = "vine.string";
	/**
	* Type checker function to determine if a value is a string.
	* Required for "unionOfTypes" functionality.
	*
	* @param value - The value to check
	* @returns True if the value is a string
	*/
	[IS_OF_TYPE] = (value) => {
		return typeof value === "string";
	};
	/**
	* Creates a new VineString instance with optional configuration.
	*
	* @param options - Field options like bail mode and nullability
	* @param validations - Initial set of validations to apply
	*/
	constructor(options, validations) {
		super(options, validations || []);
		this.dataTypeValidator = stringRule();
	}
	/**
	* Validates the value to be a valid URL.
	*
	* @param args - Optional URL validation options
	* @returns This string schema instance for method chaining
	*/
	url(...args) {
		return this.use(urlRule(...args));
	}
	/**
	* Validates the value to be an active URL by making an HTTP request.
	*
	* @returns This string schema instance for method chaining
	*/
	activeUrl() {
		return this.use(activeUrlRule());
	}
	/**
	* Validates the value to be a valid email address.
	*
	* @param args - Optional email validation options
	* @returns This string schema instance for method chaining
	*/
	email(...args) {
		return this.use(emailRule(...args));
	}
	/**
	* Validates the value to be a valid mobile phone number for specified locales.
	*
	* @param options - Optional mobile validation options including locale and strictMode
	* @returns This string schema instance for method chaining
	*
	* @example
	* vine.string().mobile({ locale: ['en-US', 'en-GB'] })
	*/
	mobile(...args) {
		return this.use(mobileRule(...args));
	}
	/**
	* Validates the value to be a valid VAT (Value Added Tax) number for specified countries.
	*
	* @param options - VAT validation options including country codes
	* @returns This string schema instance for method chaining
	*
	* @example
	* vine.string().vat({ countryCode: ['FR', 'CH', 'VE'] })
	*/
	vat(...args) {
		return this.use(vatRule(...args));
	}
	/**
	* Validates the value to be a valid IP address (IPv4 or IPv6).
	*
	* @param version - Optional IP version (4 for IPv4, 6 for IPv6). Omit to allow both.
	* @returns This string schema instance for method chaining
	*
	* @example
	* vine.string().ipAddress()     // Allows IPv4 and IPv6
	* vine.string().ipAddress(4)    // Only IPv4
	* vine.string().ipAddress(6)    // Only IPv6
	*/
	ipAddress(version) {
		return this.use(ipAddressRule(version ? { version } : void 0));
	}
	/**
	* Validates the value to be a valid hexadecimal color code.
	*
	* @returns This string schema instance for method chaining
	*
	* @example
	* vine.string().hexCode()  // Accepts #FFF, #FFFFFF, etc.
	*/
	hexCode() {
		return this.use(hexCodeRule());
	}
	/**
	* Validates the value against a custom regular expression pattern.
	*
	* @param expression - The regular expression to match against
	* @returns This string schema instance for method chaining
	*
	* @example
	* vine.string().regex(/^[A-Z]{3}\d{3}$/)  // Matches ABC123 pattern
	*/
	regex(expression) {
		return this.use(regexRule(expression));
	}
	/**
	* Validates the value to contain only alphabetic characters.
	*
	* @param options - Options to allow spaces, underscores, or dashes
	* @returns This string schema instance for method chaining
	*
	* @example
	* vine.string().alpha()
	* vine.string().alpha({ allowSpaces: true })
	* vine.string().alpha({ allowSpaces: true, allowDashes: true })
	*/
	alpha(options) {
		return this.use(alphaRule(options));
	}
	/**
	* Validates the value to contain only alphanumeric characters (letters and numbers).
	*
	* @param options - Options to allow spaces, underscores, or dashes
	* @returns This string schema instance for method chaining
	*
	* @example
	* vine.string().alphaNumeric()
	* vine.string().alphaNumeric({ allowSpaces: true, allowUnderscores: true })
	*/
	alphaNumeric(options) {
		return this.use(alphaNumericRule(options));
	}
	/**
	* Enforce a minimum length on a string field.
	*
	* @param expectedLength - The minimum required length
	* @returns This string schema instance for method chaining
	*/
	minLength(expectedLength) {
		return this.use(minLengthRule({ min: expectedLength }));
	}
	/**
	* Enforce a maximum length on a string field.
	*
	* @param expectedLength - The maximum allowed length
	* @returns This string schema instance for method chaining
	*/
	maxLength(expectedLength) {
		return this.use(maxLengthRule({ max: expectedLength }));
	}
	/**
	* Enforce a fixed length on a string field.
	*
	* @param expectedLength - The exact required length
	* @returns This string schema instance for method chaining
	*/
	fixedLength(expectedLength) {
		return this.use(fixedLengthRule({ size: expectedLength }));
	}
	/**
	* Ensures the field is confirmed by having another field with "_confirmation" suffix
	* (or a custom suffix). Useful for password confirmation fields.
	*
	* @param options - Optional configuration for the confirmation field name
	* @returns This string schema instance for method chaining
	*
	* @example
	* // Validates that "password_confirmation" field matches "password"
	* vine.string().confirmed()
	*
	* @example
	* // Custom confirmation field name
	* vine.string().confirmed({ as: 'passwordConfirm' })
	*/
	confirmed(options) {
		return this.use(confirmedRule(options));
	}
	/**
	* Trims leading and trailing whitespace from the string value.
	*
	* @returns This string schema instance for method chaining
	*
	* @example
	* vine.string().trim()  // "  hello  " becomes "hello"
	*/
	trim() {
		return this.use(trimRule());
	}
	/**
	* Normalizes the email address by applying transformations like
	* lowercasing and removing dots from Gmail addresses.
	*
	* @param options - Email normalization options
	* @returns This string schema instance for method chaining
	*
	* @example
	* vine.string().email().normalizeEmail({ gmail_remove_dots: true })
	*/
	normalizeEmail(options) {
		return this.use(normalizeEmailRule(options));
	}
	/**
	* Converts the field value to UPPERCASE.
	*
	* @returns This string schema instance for method chaining
	*
	* @example
	* vine.string().toUpperCase()  // "hello" becomes "HELLO"
	*/
	toUpperCase() {
		return this.use(toUpperCaseRule());
	}
	/**
	* Converts the field value to lowercase.
	*
	* @returns This string schema instance for method chaining
	*
	* @example
	* vine.string().toLowerCase()  // "HELLO" becomes "hello"
	*/
	toLowerCase() {
		return this.use(toLowerCaseRule());
	}
	/**
	* Converts the field value to camelCase.
	*
	* @returns This string schema instance for method chaining
	*
	* @example
	* vine.string().toCamelCase()  // "hello_world" becomes "helloWorld"
	*/
	toCamelCase() {
		return this.use(toCamelCaseRule());
	}
	/**
	* Escapes HTML entities in the string to prevent XSS attacks.
	*
	* @returns This string schema instance for method chaining
	*
	* @example
	* vine.string().escape()  // "<script>" becomes "&lt;script&gt;"
	*/
	escape() {
		return this.use(escapeRule());
	}
	/**
	* Normalizes a URL by applying standardization rules like removing trailing slashes,
	* sorting query parameters, and stripping default ports.
	*
	* @param options - URL normalization options
	* @returns This string schema instance for method chaining
	*
	* @example
	* vine.string().url().normalizeUrl({ stripWWW: true })
	*/
	normalizeUrl(...args) {
		return this.use(normalizeUrlRule(...args));
	}
	/**
	* Ensures the value starts with a specified substring.
	*
	* @param substring - The required starting substring
	* @returns This string schema instance for method chaining
	*
	* @example
	* vine.string().startsWith('https://')
	*/
	startsWith(substring) {
		return this.use(startsWithRule({ substring }));
	}
	/**
	* Ensures the value ends with a specified substring.
	*
	* @param substring - The required ending substring
	* @returns This string schema instance for method chaining
	*
	* @example
	* vine.string().endsWith('.com')
	*/
	endsWith(substring) {
		return this.use(endsWithRule({ substring }));
	}
	/**
	* Ensures the value matches the value of another field in the data.
	*
	* @param otherField - The name of the field to compare with
	* @returns This string schema instance for method chaining
	*
	* @example
	* vine.string().sameAs('password')
	*/
	sameAs(otherField) {
		return this.use(sameAsRule({ otherField }));
	}
	/**
	* Ensures the value does not match the value of another field in the data.
	*
	* @param otherField - The name of the field to compare with
	* @returns This string schema instance for method chaining
	*
	* @example
	* vine.string().notSameAs('oldPassword')
	*/
	notSameAs(otherField) {
		return this.use(notSameAsRule({ otherField }));
	}
	/**
	* Ensures the field's value is one of the predefined choices.
	*
	* @param choices - Array of allowed values or function returning allowed values
	* @returns This string schema instance for method chaining
	*
	* @example
	* vine.string().in(['red', 'green', 'blue'])
	*
	* @example
	* // Dynamic choices based on metadata
	* vine.string().in((field) => getUserRoles(field.meta.userId))
	*/
	in(choices) {
		return this.use(inRule$1({ choices }));
	}
	/**
	* Ensures the field's value is not in the predefined list.
	*
	* @param list - Array of disallowed values or function returning disallowed values
	* @returns This string schema instance for method chaining
	*
	* @example
	* vine.string().notIn(['admin', 'root', 'system'])
	*/
	notIn(list) {
		return this.use(notInRule({ list }));
	}
	/**
	* Validates the value to be a valid credit card number for specified providers.
	*
	* @param options - Credit card validation options including accepted providers
	* @returns This string schema instance for method chaining
	*
	* @example
	* vine.string().creditCard({ provider: ['visa', 'mastercard'] })
	*/
	creditCard(...args) {
		return this.use(creditCardRule(...args));
	}
	/**
	* Validates the value to be a valid passport number for specified countries.
	*
	* @param options - Passport validation options including country codes
	* @returns This string schema instance for method chaining
	*
	* @example
	* vine.string().passport({ countryCode: ['US', 'GB', 'CA'] })
	*/
	passport(...args) {
		return this.use(passportRule(...args));
	}
	/**
	* Validates the value to be a valid postal code for specified countries.
	*
	* @param options - Postal code validation options including country codes
	* @returns This string schema instance for method chaining
	*
	* @example
	* vine.string().postalCode({ countryCode: ['US', 'GB', 'CA'] })
	*/
	postalCode(...args) {
		return this.use(postalCodeRule(...args));
	}
	/**
	* Validates the value to be a valid UUID (Universally Unique Identifier).
	*
	* @param options - Optional UUID validation options including version
	* @returns This string schema instance for method chaining
	*
	* @example
	* vine.string().uuid()
	* vine.string().uuid({ version: 4 })
	*/
	uuid(...args) {
		return this.use(uuidRule(...args));
	}
	/**
	* Validates the value to be a valid ULID (Universally Unique Lexicographically Sortable Identifier).
	*
	* @returns This string schema instance for method chaining
	*
	* @example
	* vine.string().ulid()
	*/
	ulid() {
		return this.use(ulidRule());
	}
	/**
	* Validates the value contains only ASCII characters.
	*
	* @returns This string schema instance for method chaining
	*
	* @example
	* vine.string().ascii()
	*/
	ascii() {
		return this.use(asciiRule());
	}
	/**
	* Validates the value to be a valid IBAN (International Bank Account Number).
	*
	* @returns This string schema instance for method chaining
	*
	* @example
	* vine.string().iban()
	*/
	iban() {
		return this.use(ibanRule());
	}
	/**
	* Validates the value to be a valid JWT (JSON Web Token).
	*
	* @returns This string schema instance for method chaining
	*
	* @example
	* vine.string().jwt()
	*/
	jwt() {
		return this.use(jwtRule());
	}
	/**
	* Validates the value to be a string containing latitude and longitude coordinates.
	*
	* @returns This string schema instance for method chaining
	*
	* @example
	* vine.string().coordinates()  // Accepts "40.7128,-74.0060"
	*/
	coordinates() {
		return this.use(coordinatesRule());
	}
	/**
	* Clones the VineString schema type. The applied options
	* and validations are copied to the new instance.
	*
	* @returns A cloned instance of this VineString schema
	*/
	clone() {
		return new VineString(this.cloneOptions(), this.cloneValidations());
	}
};
//#endregion
//#region src/schema/number/rules.ts
/**
* Enforces the value to be a number or a string representation of a number.
* Converts string numbers to actual numbers and validates against NaN and Infinity.
*
* @example
* vine.number()
* vine.number({ strict: true })
*/
const numberRule = createRule(function number(value, options, field) {
	if (!field.isDefined) return false;
	const valueAsNumber = options.strict ? value : helpers.asNumber(value);
	if (typeof valueAsNumber !== "number" || Number.isNaN(valueAsNumber) || valueAsNumber === Number.POSITIVE_INFINITY || valueAsNumber === Number.NEGATIVE_INFINITY) {
		field.report(messages.number, "number", field);
		return false;
	}
	field.mutate(valueAsNumber, field);
	return true;
}, { toJSONSchema: (schema) => {
	schema.type = "number";
} });
/**
* Enforces a minimum value on a number field.
* The number must be greater than or equal to the specified minimum.
*
* @example
* vine.number().min(0)
* vine.number().min(18)
*/
const minRule = createRule(function min(value, options, field) {
	if (value < options.min) field.report(messages.min, "min", field, options);
}, { toJSONSchema: (schema, options) => {
	schema.minimum = options.min;
} });
/**
* Enforces a maximum value on a number field.
* The number must be less than or equal to the specified maximum.
*
* @example
* vine.number().max(100)
* vine.number().max(65)
*/
const maxRule = createRule(function max(value, options, field) {
	if (value > options.max) field.report(messages.max, "max", field, options);
}, { toJSONSchema: (schema, options) => {
	schema.maximum = options.max;
} });
/**
* Enforces the value to be within a range of minimum and maximum values.
* The number must be between min and max (inclusive).
*
* @example
* vine.number().range([1, 100])
* vine.number().range([18, 65])
*/
const rangeRule = createRule(function range(value, options, field) {
	if (value < options.min || value > options.max) field.report(messages.range, "range", field, options);
}, { toJSONSchema: (schema, options) => {
	schema.minimum = options.min;
	schema.maximum = options.max;
} });
/**
* Enforces the value to be a positive number (greater than 0).
* Zero is considered neutral and will fail this validation.
*
* @example
* vine.number().positive()
*/
const positiveRule = createRule(function positive(value, _, field) {
	if (value > 0) return;
	field.report(messages.positive, "positive", field);
}, { toJSONSchema: (schema) => {
	schema.minimum = 0;
} });
/**
* Enforces the value to be a negative number (less than 0).
* Zero is considered neutral and will fail this validation.
*
* @example
* vine.number().negative()
*/
const negativeRule = createRule(function negative(value, _, field) {
	if (value < 0) return;
	field.report(messages.negative, "negative", field);
}, { toJSONSchema: (schema) => {
	schema.exclusiveMaximum = 0;
} });
/**
* Enforces the value to be a non-negative number (greater than or equal to 0).
* Accepts zero and all positive numbers.
*
* @example
* vine.number().nonNegative()
*/
const nonNegativeRule = createRule(function nonNegative(value, _, field) {
	if (value >= 0) return;
	field.report(messages.nonNegative, "nonNegative", field);
});
/**
* Enforces the value to be a non-positive number (less than or equal to 0).
* Accepts zero and all negative numbers.
*
* @example
* vine.number().nonPositive()
*/
const nonPositiveRule = createRule(function nonPositive(value, _, field) {
	if (value <= 0) return;
	field.report(messages.nonPositive, "nonPositive", field);
});
/**
* Enforces the value to have a fixed number or range of decimal places.
* Validates the precision of the decimal number.
*
* @example
* vine.number().decimal(2)
* vine.number().decimal([0, 2])
*/
const decimalRule = createRule(function decimal(value, options, field) {
	if (!helpers.isDecimal(String(value), {
		force_decimal: options.range[0] !== 0,
		decimal_digits: options.range.join(",")
	})) field.report(messages.decimal, "decimal", field, { digits: options.range.join("-") });
});
/**
* Enforces the value to be an integer without decimal places.
* The number must be a whole number.
*
* @example
* vine.number().withoutDecimals()
*/
const withoutDecimalsRule = createRule(function withoutDecimals(value, _, field) {
	if (!Number.isInteger(value)) field.report(messages.withoutDecimals, "withoutDecimals", field);
}, { toJSONSchema: (schema) => {
	schema.type = "integer";
} });
/**
* Enforces the value to be one of the specified allowed values.
* The number must match one of the values in the provided list.
*
* @example
* vine.number().in([1, 2, 3, 5, 8, 13])
* vine.number().in([10, 20, 30])
*/
const inRule = createRule(function inValues(value, options, field) {
	if (!options.values.includes(value)) field.report(messages["number.in"], "in", field, options);
}, { toJSONSchema: (schema, options) => {
	schema.enum = options.values;
} });
//#endregion
//#region src/schema/number/main.ts
/**
* VineNumber represents a numeric value in the validation schema.
* It accepts both string and number inputs and converts them to numbers,
* with comprehensive validation for ranges, decimals, and sign constraints.
*
* @example
* const schema = vine.number()
*   .min(0)
*   .max(100)
*   .decimal([0, 2])
*
* const result = await vine.validate({
*   schema,
*   data: "42.5"
* })
*/
var VineNumber = class VineNumber extends BaseLiteralType {
	/**
	* Static collection of all available validation rules for numbers
	*/
	static rules = {
		in: inRule,
		max: maxRule,
		min: minRule,
		range: rangeRule,
		number: numberRule,
		decimal: decimalRule,
		negative: negativeRule,
		positive: positiveRule,
		nonNegativeRule,
		nonPositiveRule,
		withoutDecimals: withoutDecimalsRule
	};
	/**
	* The subtype identifier for the literal schema field
	*/
	[SUBTYPE] = "number";
	/**
	* Unique name identifier for union type resolution
	*/
	[UNIQUE_NAME] = "vine.number";
	/**
	* Type checker function to determine if a value can be converted to a number.
	* Required for "unionOfTypes" functionality.
	*
	* @param value - The value to check
	* @returns True if the value can be converted to a valid number
	*/
	[IS_OF_TYPE] = (value) => {
		const valueAsNumber = helpers.asNumber(value);
		return !Number.isNaN(valueAsNumber);
	};
	/**
	* Creates a new VineNumber instance with optional configuration.
	*
	* @param options - Field options like bail mode, nullability and strict mode
	* @param validations - Initial set of validations to apply
	*/
	constructor(options, validations) {
		super(options, validations || []);
		this.dataTypeValidator = numberRule(options || {});
	}
	/**
	* Enforce a minimum value for the number input.
	*
	* @param value - The minimum allowed value
	* @returns This number schema instance for method chaining
	*/
	min(value) {
		return this.use(minRule({ min: value }));
	}
	/**
	* Enforce a maximum value for the number input.
	*
	* @param value - The maximum allowed value
	* @returns This number schema instance for method chaining
	*/
	max(value) {
		return this.use(maxRule({ max: value }));
	}
	/**
	* Enforce value to be within the range of minimum and maximum values.
	*
	* @param value - Tuple containing [min, max] values
	* @returns This number schema instance for method chaining
	*/
	range(value) {
		return this.use(rangeRule({
			min: value[0],
			max: value[1]
		}));
	}
	/**
	* Enforces the value to be a positive number (greater than 0).
	*
	* @returns This number schema instance for method chaining
	*
	* @example
	* vine.number().positive()  // Accepts 1, 100.5, etc. Rejects 0, -1
	*/
	positive() {
		return this.use(positiveRule());
	}
	/**
	* Enforces the value to be a negative number (less than 0).
	*
	* @returns This number schema instance for method chaining
	*
	* @example
	* vine.number().negative()  // Accepts -1, -100.5, etc. Rejects 0, 1
	*/
	negative() {
		return this.use(negativeRule());
	}
	/**
	* Enforces the value to be a non-negative number (greater than or equal to 0).
	*
	* @returns This number schema instance for method chaining
	*
	* @example
	* vine.number().nonNegative()  // Accepts 0, 1, 100.5, etc. Rejects -1
	*/
	nonNegative() {
		return this.use(nonNegativeRule());
	}
	/**
	* Enforces the value to be a non-positive number (less than or equal to 0).
	*
	* @returns This number schema instance for method chaining
	*
	* @example
	* vine.number().nonPositive()  // Accepts 0, -1, -100.5, etc. Rejects 1
	*/
	nonPositive() {
		return this.use(nonPositiveRule());
	}
	/**
	* Enforces the value to have a fixed number or range of decimal places.
	*
	* @param range - Exact number of decimal places or [min, max] range
	* @returns This number schema instance for method chaining
	*
	* @example
	* vine.number().decimal(2)       // Accepts 1.23, rejects 1.2 or 1.234
	* vine.number().decimal([0, 2])  // Accepts 1, 1.2, 1.23
	*/
	decimal(range) {
		return this.use(decimalRule({ range: Array.isArray(range) ? range : [range] }));
	}
	/**
	* Enforces the value to be an integer without decimal places.
	*
	* @returns This number schema instance for method chaining
	*
	* @example
	* vine.number().withoutDecimals()  // Accepts 42, -10, rejects 42.5
	*/
	withoutDecimals() {
		return this.use(withoutDecimalsRule());
	}
	/**
	* Clones the VineNumber schema type. The applied options
	* and validations are copied to the new instance.
	*
	* @returns A cloned instance of this VineNumber schema
	*/
	clone() {
		return new VineNumber(this.cloneOptions(), this.cloneValidations());
	}
	/**
	* Enforces the value to be one of the specified allowed values.
	*
	* @param values - Array of allowed numeric values
	* @returns This number schema instance for method chaining
	*
	* @example
	* vine.number().in([1, 2, 3, 5, 8, 13])  // Only Fibonacci numbers allowed
	*/
	in(values) {
		return this.use(inRule({ values }));
	}
};
//#endregion
//#region src/schema/boolean/rules.ts
/**
* Validates the value to be a boolean
*/
const booleanRule = createRule(function boolean(value, options, field) {
	const valueAsBoolean = options.strict === true ? value : helpers.asBoolean(value);
	if (typeof valueAsBoolean !== "boolean") {
		field.report(messages.boolean, "boolean", field);
		return;
	}
	field.mutate(valueAsBoolean, field);
}, { toJSONSchema: (schema, { strict = false }) => {
	if (strict) schema.type = "boolean";
	else schema.enum = [...BOOLEAN_POSITIVES, ...BOOLEAN_NEGATIVES];
} });
//#endregion
//#region src/schema/boolean/main.ts
/**
* VineBoolean represents a boolean value in the validation schema.
* It accepts boolean, string, and number inputs and converts them to booleans,
* with support for both strict and loose type checking.
*
* @example
* const schema = vine.boolean()
*
* const result = await vine.validate({
*   schema,
*   data: "true" // Will be converted to true
* })
*/
var VineBoolean = class VineBoolean extends BaseLiteralType {
	/**
	* Static collection of all available validation rules for booleans
	*/
	static rules = { boolean: booleanRule };
	/**
	* The subtype identifier for the literal schema field
	*/
	[SUBTYPE] = "boolean";
	/**
	* Unique name identifier for union type resolution
	*/
	[UNIQUE_NAME] = "vine.boolean";
	/**
	* Type checker function to determine if a value can be converted to a boolean.
	* Required for "unionOfTypes" functionality.
	*
	* @param value - The value to check
	* @returns True if the value can be converted to a boolean
	*/
	[IS_OF_TYPE] = (value) => {
		return typeof (this.options.strict === true ? value : helpers.asBoolean(value)) === "boolean";
	};
	/**
	* Creates a new VineBoolean instance with optional configuration.
	*
	* @param options - Field options like bail mode, nullability and strict mode
	* @param validations - Initial set of validations to apply
	*/
	constructor(options, validations) {
		super(options, validations || [booleanRule(options || {})]);
	}
	/**
	* Clones the VineBoolean schema type. The applied options
	* and validations are copied to the new instance.
	*
	* @returns A cloned instance of this VineBoolean schema
	*/
	clone() {
		return new VineBoolean(this.cloneOptions(), this.cloneValidations());
	}
};
//#endregion
//#region src/schema/literal/rules.ts
/**
* Validates that two values are equal, considering HTML form serialization behavior.
* Compares values using normalized comparison that handles type coercion.
*
* @example
* vine.literal('admin')
* vine.literal(42)
* vine.literal(true)
*/
const equalsRule = createRule(function equals(value, options, field) {
	const comparedValue = helpers.compareValues(value, options.expectedValue);
	/**
	* Performing validation and reporting error
	*/
	if (!comparedValue.isEqual) {
		field.report(messages.literal, "literal", field, options);
		return;
	}
	/**
	* Mutating input with normalized value
	*/
	field.mutate(comparedValue.casted, field);
});
//#endregion
//#region src/schema/literal/main.ts
/**
* VineLiteral represents a schema type that matches an exact literal value.
* It validates that the input exactly matches the specified literal value,
* supporting string, number, boolean, and null literals.
*
* @example
* const schema = vine.literal('admin')
*
* const result = await vine.validate({
*   schema,
*   data: 'admin'
* })
*/
var VineLiteral = class VineLiteral extends BaseLiteralType {
	/**
	* Static collection of all available validation rules for literals
	*/
	static rules = { equals: equalsRule };
	/**
	* The literal value that must be matched
	*/
	#value;
	/**
	* The subtype identifier for the literal schema field
	*/
	[SUBTYPE] = "literal";
	/**
	* Type checker function to determine if a value matches the literal value.
	* Required for "unionOfTypes" functionality.
	*
	* @param value - The value to check
	* @returns True if the value matches the literal value
	*/
	[IS_OF_TYPE] = (value) => {
		return helpers.compareValues(value, this.#value).isEqual;
	};
	/**
	* Creates a new VineLiteral instance with the specified literal value.
	*
	* @param value - The exact literal value to match
	* @param options - Field options like bail mode and nullability
	* @param validations - Initial set of validations to apply
	*/
	constructor(value, options, validations) {
		super(options, validations || [equalsRule({ expectedValue: value })]);
		this.#value = value;
		this[UNIQUE_NAME] = `vine.literal.${this.#value}`;
	}
	/**
	* Clones the VineLiteral schema type. The applied options
	* and validations are copied to the new instance.
	*
	* @returns A cloned instance of this VineLiteral schema
	*/
	clone() {
		return new VineLiteral(this.#value, this.cloneOptions(), this.cloneValidations());
	}
	/**
	* Converts the schema to JSON Schema format.
	* Generates an enum constraint with the literal value.
	*/
	toJSONSchema() {
		const schema = super.toJSONSchema();
		if (typeof this.#value === "string") {
			schema.type = "string";
			schema.enum = [this.#value];
		}
		if (typeof this.#value === "boolean") {
			schema.type = "boolean";
			schema.enum = [this.#value];
		}
		if (typeof this.#value === "number") {
			schema.type = "number";
			schema.enum = [this.#value];
		}
		return schema;
	}
};
//#endregion
//#region src/schema/accepted/rules.ts
/**
* Array of accepted values for checkbox/acceptance validation
*/
const ACCEPTED_VALUES = [
	"on",
	"1",
	"yes",
	"true",
	true,
	1
];
/**
* Validates that the value is present and has one of the accepted values.
* This rule is used for checkbox and acceptance field validation.
*
* Accepted values are:
* - "on" (HTML checkbox default when checked)
* - "1" (string)
* - "yes" (string)
* - "true" (string)
* - true (boolean)
* - 1 (number)
*
* @example
* vine.accepted()
*
* @example
* vine.string().use(acceptedRule())
*/
const acceptedRule = createRule(function accepted(value, _, field) {
	if (!ACCEPTED_VALUES.includes(value)) field.report(messages.accepted, "accepted", field);
});
//#endregion
//#region src/schema/accepted/main.ts
/**
* VineAccepted represents a checkbox or acceptance field that must be
* checked or have an accepted value. This is commonly used for terms
* of service acceptance, privacy policy agreements, etc.
*
* Accepted values are: 'on', '1', 'yes', 'true', true, or 1
* The output is always normalized to the boolean value `true`.
*
* @example
* const schema = vine.object({
*   termsAccepted: vine.accepted(),
*   newsletter: vine.accepted().optional()
* })
*
* @example
* // HTML form checkbox
* // <input type="checkbox" name="terms" />
* // When checked, sends "on" which is accepted
*/
var VineAccepted = class VineAccepted extends BaseLiteralType {
	/**
	* Static collection of all available validation rules for accepted fields
	*/
	static rules = { accepted: acceptedRule };
	/**
	* The subtype identifier for the literal schema field
	*/
	[SUBTYPE] = "checkbox";
	/**
	* Creates a new VineAccepted instance.
	*
	* @param options - Field options like bail mode and nullability
	* @param validations - Initial set of validations to apply
	*/
	constructor(options, validations) {
		super(options, validations || [acceptedRule()]);
	}
	/**
	* Clones the VineAccepted schema type. The applied options
	* and validations are copied to the new instance.
	*
	* @returns A cloned instance of this VineAccepted schema
	*/
	clone() {
		return new VineAccepted(this.cloneOptions(), this.cloneValidations());
	}
};
//#endregion
//#region src/schema/object/group.ts
/**
* ObjectGroup represents a collection of conditional property sets that can be
* merged into an object based on runtime conditions. This enables dynamic schema
* composition where different properties are validated based on conditional logic.
*
* @template Conditional - The type of conditional used in this group
*
* @example
* const schema = vine.object({
*   type: vine.string()
* }).merge(
*   vine.group([
*     vine.group.if((value) => value.type === 'user', {
*       username: vine.string()
*     }),
*     vine.group.if((value) => value.type === 'admin', {
*       permissions: vine.array(vine.string())
*     })
*   ])
* )
*/
var ObjectGroup = class ObjectGroup {
	/**
	* Array of conditional property sets to evaluate
	*/
	#conditionals;
	/**
	* Callback invoked when no conditional matches. Defaults to reporting an error.
	*/
	#otherwiseCallback = (_, field) => {
		field.report(messages.unionGroup, "unionGroup", field);
	};
	/**
	* Creates a new ObjectGroup with the specified conditionals.
	*
	* @param conditionals - Array of conditional property sets to evaluate
	*/
	constructor(conditionals) {
		this.#conditionals = conditionals;
	}
	/**
	* Converts the object group to JSON Schema format using anyOf.
	*
	* @returns JSON Schema representation of this group
	*/
	toJSONSchema() {
		return { anyOf: this.#conditionals.map((conditional) => conditional.toJSONSchema()) };
	}
	/**
	* Clones the ObjectGroup including all conditionals and the otherwise callback.
	*
	* @returns A cloned instance of this ObjectGroup
	*/
	clone() {
		const cloned = new ObjectGroup(this.#conditionals);
		cloned.otherwise(this.#otherwiseCallback);
		return cloned;
	}
	/**
	* Defines a fallback callback to invoke when none of the group conditions match.
	* By default, this reports a validation error. Use this method to customize
	* the error handling behavior.
	*
	* @param callback - Callback to invoke when no condition matches
	* @returns This group instance for method chaining
	*
	* @example
	* vine.group([
	*   vine.group.if((value) => value.type === 'user', { username: vine.string() }),
	*   vine.group.if((value) => value.type === 'admin', { role: vine.string() })
	* ]).otherwise((value, field) => {
	*   field.report('Invalid type specified', 'invalidType', field)
	* })
	*/
	otherwise(callback) {
		this.#otherwiseCallback = callback;
		return this;
	}
	/**
	* Compiles the group to a compiler node for validation.
	*
	* @param refs - Reference store for the compiler
	* @param options - Parser options
	* @returns Compiled object group node
	*/
	[PARSE](refs, options) {
		return {
			type: "group",
			elseConditionalFnRefId: refs.trackConditional(this.#otherwiseCallback),
			conditions: this.#conditionals.map((conditional) => conditional[PARSE](refs, options))
		};
	}
};
//#endregion
//#region src/schema/object/conditional.ts
/**
* GroupConditional represents a subset of object properties that are conditionally
* validated and merged based on a runtime condition. This allows schemas to have
* different required fields depending on the values in the object being validated.
*
* @template Properties - Record of property names to their schema types
* @template Input - Expected input type for these properties
* @template Output - Output type after validation and transformation
* @template CamelCaseOutput - Output type with camelCase property names
*
* @example
* vine.group.if(
*   (value) => value.shipping_required === true,
*   {
*     shipping_address: vine.string(),
*     shipping_method: vine.string()
*   }
* )
*/
var GroupConditional = class {
	/**
	* Properties to validate and merge when the conditional evaluates to true
	*/
	#properties;
	/**
	* Conditional function that determines whether to validate these properties
	*/
	#conditional;
	/**
	* Creates a new GroupConditional with a condition and properties.
	*
	* @param conditional - Function that returns truthy value when properties should be validated
	* @param properties - Properties to validate and merge when condition is true
	*/
	constructor(conditional, properties) {
		this.#properties = properties;
		this.#conditional = conditional;
	}
	/**
	* Converts the conditional properties to JSON Schema format.
	*
	* @returns JSON Schema representation of this conditional's properties
	*/
	toJSONSchema() {
		const properties = {};
		const required = [];
		for (const [key, property] of Object.entries(this.#properties)) {
			properties[key] = property.toJSONSchema();
			if (!("isOptional" in property) || property.isOptional !== true) required.push(key);
		}
		return {
			type: "object",
			properties,
			required
		};
	}
	/**
	* Compiles the conditional to a compiler node for validation.
	*
	* @param refs - Reference store for the compiler
	* @param options - Parser options
	* @returns Compiled conditional node
	*/
	[PARSE](refs, options) {
		return {
			schema: {
				type: "sub_object",
				properties: Object.keys(this.#properties).map((property) => {
					return this.#properties[property][PARSE](property, refs, options);
				}),
				groups: []
			},
			conditionalFnRefId: refs.trackConditional(this.#conditional)
		};
	}
};
//#endregion
//#region src/schema/object/group_builder.ts
/**
* Creates an object group that conditionally merges properties into an existing object
* based on runtime validation logic. Groups enable dynamic schema composition where
* different properties are required based on conditional rules.
*
* @param conditionals - Array of conditional property sets to evaluate
* @returns ObjectGroup instance that can be merged into a VineObject
*
* @example
* const schema = vine.object({
*   account_type: vine.string()
* }).merge(
*   vine.group([
*     vine.group.if((value) => value.account_type === 'personal', {
*       first_name: vine.string(),
*       last_name: vine.string()
*     }),
*     vine.group.if((value) => value.account_type === 'business', {
*       company_name: vine.string(),
*       tax_id: vine.string()
*     })
*   ])
* )
*/
function group(conditionals) {
	return new ObjectGroup(conditionals);
}
/**
* Wraps object properties inside a conditional statement that evaluates at validation time.
* Properties are only validated and merged if the condition returns a truthy value.
*
* @param conditon - Callback function that receives the object value and field context
* @param properties - Properties to merge when the condition is truthy
* @returns GroupConditional instance for use in vine.group()
*
* @example
* vine.group([
*   vine.group.if(
*     (value) => value.type === 'admin',
*     {
*       permissions: vine.array(vine.string()),
*       access_level: vine.number()
*     }
*   ),
*   vine.group.if(
*     (value) => value.type === 'user',
*     {
*       username: vine.string()
*     }
*   )
* ])
*/
group.if = function groupIf(conditon, properties) {
	return new GroupConditional(conditon, properties);
};
/**
* Wraps object properties inside an "else" condition that always evaluates to true.
* Use this as a fallback when no other conditions in the group match.
*
* @param properties - Properties to merge when no other condition matches
* @returns GroupConditional instance that always matches
*
* @example
* vine.group([
*   vine.group.if((value) => value.role === 'admin', {
*     admin_key: vine.string()
*   }),
*   vine.group.else({
*     user_key: vine.string()
*   })
* ])
*/
group.else = function groupElse(properties) {
	return new GroupConditional(() => true, properties);
};
//#endregion
//#region src/schema/enum/native_enum.ts
/**
* VineNativeEnum represents an enum data type that performs validation
* against a pre-defined choices list.
*
* The choices list is derived from TypeScript enum data type or an
* object with string or number values. This allows you to validate
* against native TypeScript enums.
*
* @template Values - The enum-like type containing allowed values
*
* @example
* enum Status {
*   Active = 'active',
*   Inactive = 'inactive'
* }
*
* const schema = vine.nativeEnum(Status)
*
* @example
* const Colors = {
*   RED: 'red',
*   BLUE: 'blue',
*   GREEN: 'green'
* } as const
*
* const schema = vine.nativeEnum(Colors)
*/
var VineNativeEnum = class VineNativeEnum extends BaseLiteralType {
	/**
	* Static collection of all available validation rules for native enums
	*/
	static rules = { enum: enumRule };
	/**
	* The enum-like object containing allowed values
	*/
	#values;
	/**
	* The subtype identifier for the literal schema field
	*/
	[SUBTYPE] = "enum";
	/**
	* Creates a new VineNativeEnum instance with the specified enum values.
	*
	* @param values - The enum or enum-like object containing allowed values
	* @param options - Field options like bail mode and nullability
	* @param validations - Initial set of validations to apply
	*/
	constructor(values, options, validations) {
		super(options, validations || [enumRule({ choices: Object.values(values) })]);
		this.#values = values;
	}
	/**
	* Clones the VineNativeEnum schema type. The applied options
	* and validations are copied to the new instance.
	*
	* @returns A cloned instance of this VineNativeEnum schema
	*/
	clone() {
		return new VineNativeEnum(this.#values, this.cloneOptions(), this.cloneValidations());
	}
};
//#endregion
//#region src/schema/native_file/rules.ts
/**
* Validates that the value is an instance of the platform native File class.
* This is the primary type validator for native file fields.
*
* @example
* vine.string().use(isNativeFileRule())
*/
const isNativeFileRule = createRule(function file(value, _, field) {
	if (!field.isDefined) return false;
	if (value instanceof File === false) {
		field.report(messages.nativeFile, "nativeFile", field);
		return false;
	}
	return true;
});
/**
* Validates that the file size is at least the specified minimum size in bytes.
*
* @example
* vine.file().use(minSizeRule({ min: 1024 })) // At least 1KB
*
* @example
* vine.file().minSize(1024) // Shorthand method
*/
const minSizeRule = createRule(function minSize(value, options, field) {
	if (value.size < options.min) {
		field.report(messages["nativeFile.minSize"], "nativeFile.minSize", field, options);
		return false;
	}
	return true;
});
/**
* Validates that the file size does not exceed the specified maximum size in bytes.
*
* @example
* vine.file().use(maxSizeRule({ max: 2097152 })) // Max 2MB
*
* @example
* vine.file().maxSize(2097152) // Shorthand method
*/
const maxSizeRule = createRule(function minSize(value, options, field) {
	if (value.size > options.max) field.report(messages["nativeFile.maxSize"], "nativeFile.maxSize", field, options);
});
/**
* Validates that the file's MIME type is one of the allowed types.
*
* @example
* vine.file().use(mimeTypesRule({
*   mimeTypes: ['image/jpeg', 'image/png']
* }))
*
* @example
* vine.file().mimeTypes(['image/jpeg', 'image/png']) // Shorthand method
*/
const mimeTypesRule = createRule((value, options, field) => {
	const mimeType = value.type;
	if (!options.mimeTypes.includes(mimeType)) field.report(messages["nativeFile.mimeTypes"], "nativeFile.mimeTypes", field, options);
});
//#endregion
//#region src/schema/native_file/main.ts
/**
* VineNativeFile represents a platform native File class instance.
* This type is used to validate file uploads in browser environments
* where the File API is available.
*
* The file is validated based on type, size, and MIME type constraints.
* Unlike MultipartFile (used in Node.js), this works with the browser's
* native File object from file input elements.
*
* @example
* const schema = vine.object({
*   avatar: vine.file().maxSize('2mb').mimeTypes(['image/jpeg', 'image/png']),
*   document: vine.file().minSize('1kb').maxSize('10mb')
* })
*
* @example
* // From HTML file input
* // <input type="file" name="avatar" />
* const file = event.target.files[0] // This is a native File instance
*/
var VineNativeFile = class VineNativeFile extends BaseLiteralType {
	/**
	* Static collection of all available validation rules for native files
	*/
	static rules = {
		maxSize: maxSizeRule,
		mimeTypes: mimeTypesRule,
		minSize: minSizeRule
	};
	/**
	* The subtype identifier for the literal schema field
	*/
	[SUBTYPE] = "nativeFile";
	/**
	* Unique name identifier for union type resolution
	*/
	[UNIQUE_NAME] = "vine.nativeFile";
	/**
	* Type checker function to determine if a value is a native file.
	* Required for "unionOfTypes" functionality.
	*
	* @param value - The value to check
	*/
	[IS_OF_TYPE] = (value) => {
		return value instanceof File;
	};
	/**
	* Creates a new VineNativeFile instance.
	*
	* @param options - Field options like bail mode and nullability
	* @param validations - Initial set of validations to apply
	*/
	constructor(options, validations) {
		super(options, validations || []);
		this.dataTypeValidator = isNativeFileRule();
	}
	/**
	* Clones the VineNativeFile schema type. The applied options
	* and validations are copied to the new instance.
	*
	* @returns A cloned instance of this VineNativeFile schema
	*/
	clone() {
		return new VineNativeFile(this.cloneOptions(), this.cloneValidations());
	}
	/**
	* Enforce the file size to be at least the provided minimum size.
	*
	* @param size - Minimum file size in bytes
	*
	* @example
	* vine.file().minSize(1024) // At least 1KB
	*/
	minSize(size) {
		return this.use(minSizeRule({ min: size }));
	}
	/**
	* Limit the maximum file size.
	*
	* @param size - Maximum file size in bytes
	*
	* @example
	* vine.file().maxSize(2097152) // Max 2MB
	*/
	maxSize(size) {
		return this.use(maxSizeRule({ max: size }));
	}
	/**
	* Enforce the file type to be one of the specified MIME types.
	*
	* @param types - Array of allowed MIME types
	*
	* @example
	* vine.file().mimeTypes(['image/jpeg', 'image/png', 'image/gif'])
	*
	* @example
	* vine.file().mimeTypes(['application/pdf'])
	*/
	mimeTypes(types) {
		return this.use(mimeTypesRule({ mimeTypes: types }));
	}
};
//#endregion
//#region src/schema/union_of_types/main.ts
/**
* Vine union of types represents a union data type that automatically
* determines which schema to apply based on the value's type.
*
* Unlike regular unions that require explicit conditionals, unionOfTypes
* uses each schema's IS_OF_TYPE method to automatically detect the
* appropriate schema based on the input value's type.
*
* @template Schema - The schema types that make up this union
*
* @example
* const schema = vine.unionOfTypes([
*   vine.string(),
*   vine.number(),
*   vine.boolean()
* ])
*
* @example
* const schema = vine.unionOfTypes([
*   vine.object({ type: vine.literal('user'), name: vine.string() }),
*   vine.object({ type: vine.literal('admin'), permissions: vine.array(vine.string()) })
* ])
*/
var VineUnionOfTypes = class VineUnionOfTypes {
	/**
	* Array of schemas to match against
	*/
	#schemas;
	/**
	* Callback to invoke when no schema type matches
	*/
	#otherwiseCallback = (_, field) => {
		field.report(messages.unionOfTypes, "unionOfTypes", field);
	};
	/**
	* Creates a new VineUnionOfTypes instance with the specified schemas.
	*
	* @param schemas - Array of schemas to match against input values
	*/
	constructor(schemas) {
		this.#schemas = schemas;
	}
	/**
	* Define a fallback method to invoke when all of the union conditions
	* fail. You may use this method to report an error.
	*/
	otherwise(callback) {
		this.#otherwiseCallback = callback;
		return this;
	}
	/**
	* Clones the VineUnionOfTypes schema type.
	*/
	clone() {
		const cloned = new VineUnionOfTypes(this.#schemas.map((schema) => schema.clone()));
		cloned.otherwise(this.#otherwiseCallback);
		return cloned;
	}
	/**
	* Mark the field under validation as optional. An optional
	* field allows both null and undefined values.
	*/
	optional() {
		return new VineUnionOfTypes([new VineOptional(), ...this.#schemas]);
	}
	/**
	* 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.
	*/
	nullable() {
		return new VineUnionOfTypes([new VineNull(), ...this.#schemas]);
	}
	/**
	* Transforms into JSONSchema.
	*/
	toJSONSchema() {
		return { anyOf: this.#schemas.map((schema) => schema.toJSONSchema?.()).filter(Boolean) };
	}
	/**
	* Compiles the union of types schema to a compiler node.
	*
	* Creates conditional branches for each schema using their IS_OF_TYPE
	* methods to determine which schema matches the input value.
	*
	* @param propertyName - The name of the property being validated
	* @param refs - Reference store for tracking validators and conditionals
	* @param options - Parser options including camelCase transformation
	*/
	[PARSE](propertyName, refs, options) {
		return {
			type: "union",
			fieldName: propertyName,
			propertyName: options.toCamelCase ? camelcase(propertyName) : propertyName,
			elseConditionalFnRefId: refs.trackConditional(this.#otherwiseCallback),
			conditions: this.#schemas.map((schema) => {
				return {
					conditionalFnRefId: refs.trackConditional((value, field) => {
						return schema[IS_OF_TYPE](value, field);
					}),
					schema: schema[PARSE](propertyName, refs, options)
				};
			})
		};
	}
};
//#endregion
//#region src/schema/builder.ts
/**
* 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
* const builder = new SchemaBuilder()
* const schema = builder.object({
*   name: builder.string(),
*   age: builder.number().min(0),
*   email: builder.string().email()
* })
*/
var SchemaBuilder = class extends Macroable {
	/**
	* Define a sub-object as a conditional union group.
	* Groups allow creating conditional validations based on discriminator fields.
	*
	* @example
	* vine.group([
	*   vine.group.if(vine.string(), vine.object({ name: vine.string() }))
	* ])
	*/
	group = group;
	/**
	* Define a union of multiple schema types.
	* Union schemas attempt to validate against each schema until one succeeds.
	*
	* @example
	* vine.union([
	*   vine.string(),
	*   vine.number()
	* ])
	*/
	union = union;
	/**
	* Define a string value schema with comprehensive validation rules.
	*
	* @returns A VineString schema instance
	*
	* @example
	* vine.string().email().minLength(5)
	*/
	string() {
		return new VineString();
	}
	/**
	* Define a boolean value schema with optional strict mode.
	*
	* @param options - Configuration options for boolean validation
	* @returns A VineBoolean schema instance
	*
	* @example
	* vine.boolean({ strict: true }) // Only accepts true/false
	*/
	boolean(options) {
		return new VineBoolean(options);
	}
	/**
	* Validate a checkbox or acceptance field to be checked/accepted.
	*
	* @returns A VineAccepted schema instance
	*
	* @example
	* vine.accepted() // Validates terms acceptance
	*/
	accepted() {
		return new VineAccepted();
	}
	/**
	* Define a number value schema with optional strict mode.
	*
	* @param options - Configuration options for number validation
	* @returns A VineNumber schema instance
	*
	* @example
	* vine.number().min(0).max(100)
	*/
	number(options) {
		return new VineNumber(options);
	}
	/**
	* Define a datetime value schema with optional parsing options.
	*
	* @param options - Configuration options for date validation
	* @returns A VineDate schema instance
	*
	* @example
	* vine.date({ formats: ['YYYY-MM-DD'] })
	*/
	date(options) {
		return new VineDate(options);
	}
	/**
	* Define a schema type that validates input matches a specific literal value.
	* Useful for validating exact strings, numbers, or boolean values.
	*
	* @template Value - The literal value type to validate against
	* @param value - The exact value that input must match
	* @returns A VineLiteral schema instance
	*
	* @example
	* vine.literal('hello') // Only accepts "hello"
	* vine.literal(42)      // Only accepts 42
	* vine.literal(true)    // Only accepts true
	*/
	literal(value) {
		return new VineLiteral(value);
	}
	/**
	* Define an optional value that can be undefined.
	* Chain the "nullable" method to also allow null values in the output.
	*
	* @returns A VineOptional schema instance
	*
	* @example
	* vine.optional() // Accepts undefined
	* vine.optional().nullable() // Accepts undefined or null
	*/
	optional() {
		return new VineOptional();
	}
	/**
	* Define a schema that only accepts null values.
	*
	* @returns A VineNull schema instance
	*
	* @example
	* vine.null() // Only accepts null
	*/
	null() {
		return new VineNull();
	}
	/**
	* Define an object schema with known properties and their validation schemas.
	* You may call "allowUnknownProperties" to merge unknown properties into the output.
	*
	* @template Properties - Record of property names to their schema types
	* @param properties - Object defining the schema for each property
	* @returns A VineObject schema instance
	*
	* @example
	* vine.object({
	*   name: vine.string().minLength(2),
	*   age: vine.number().min(0),
	*   email: vine.string().email().optional()
	* })
	*/
	object(properties) {
		return new VineObject(properties);
	}
	/**
	* Define an array schema that validates each element against a given schema.
	* All elements in the array must conform to the same schema type.
	*
	* @template Schema - The schema type for validating array elements
	* @param schema - The schema to validate each array element against
	* @returns A VineArray schema instance
	*
	* @example
	* vine.array(vine.string()) // Array of strings
	* vine.array(vine.object({ id: vine.number() })) // Array of objects
	*/
	array(schema) {
		return new VineArray(schema);
	}
	/**
	* Define a tuple schema with fixed length where each element
	* can have its own validation schema.
	*
	* @template Schema - Array of schema types for each tuple position
	* @param schemas - Array of schemas for each tuple element
	* @returns A VineTuple schema instance
	*
	* @example
	* vine.tuple([
	*   vine.string(),   // First element must be string
	*   vine.number(),   // Second element must be number
	*   vine.boolean()   // Third element must be boolean
	* ])
	*/
	tuple(schemas) {
		return new VineTuple(schemas);
	}
	/**
	* Define a record (dictionary) schema with unknown string keys
	* and values that conform to a specific schema type.
	*
	* @template Schema - The schema type for validating record values
	* @param schema - The schema to validate each record value against
	* @returns A VineRecord schema instance
	*
	* @example
	* vine.record(vine.string()) // { [key: string]: string }
	* vine.record(vine.number()) // { [key: string]: number }
	*/
	record(schema) {
		return new VineRecord(schema);
	}
	enum(values) {
		if (Array.isArray(values) || typeof values === "function") return new VineEnum(values);
		return new VineNativeEnum(values);
	}
	/**
	* Define a schema that accepts any value without validation.
	* Use sparingly as it bypasses type safety and validation.
	*
	* @returns A VineAny schema instance
	*
	* @example
	* vine.any() // Accepts any value: string, number, object, etc.
	*/
	any() {
		return new VineAny();
	}
	/**
	* 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.
	*
	* @template Schema - The schema types in the union
	* @param schemas - Array of distinct schema types for the union
	* @returns A VineUnionOfTypes schema instance
	* @throws {Error} When schemas are not compatible or duplicated
	*
	* @example
	* vine.unionOfTypes([
	*   vine.string(),
	*   vine.number(),
	*   vine.boolean()
	* ])
	*
	* // For objects with discriminator fields
	* vine.unionOfTypes([
	*   vine.object({ type: vine.literal('user'), name: vine.string() }),
	*   vine.object({ type: vine.literal('admin'), permissions: vine.array(vine.string()) })
	* ])
	*/
	unionOfTypes(schemas) {
		const schemasInUse = /* @__PURE__ */ new Set();
		schemas.forEach((schema) => {
			if (!schema[IS_OF_TYPE] || !schema[UNIQUE_NAME]) throw new Error(`Cannot use "${schema.constructor.name}". The schema type is not compatible for use with "vine.unionOfTypes"`);
			if (schemasInUse.has(schema[UNIQUE_NAME])) throw new Error(`Cannot use duplicate schema "${schema[UNIQUE_NAME]}". "vine.unionOfTypes" needs distinct schema types only`);
			schemasInUse.add(schema[UNIQUE_NAME]);
		});
		schemasInUse.clear();
		return new VineUnionOfTypes(schemas);
	}
	/**
	* Define a schema that validates native File instances.
	* Useful for file upload validation in web applications.
	*
	* @returns A VineNativeFile schema instance
	*
	* @example
	* vine.nativeFile()
	*   .maxSize(1024 * 1024)
	*   .mimeTypes(['image/png', 'image/jpeg'])
	*/
	nativeFile() {
		return new VineNativeFile();
	}
};
//#endregion
//#region src/vine/validator.ts
/**
* Error messages to share with the compiler.
* Maps core validation types to their default error messages.
*/
const COMPILER_ERROR_MESSAGES = {
	required: messages.required,
	array: messages.array,
	object: messages.object
};
/**
* Reusable empty object to avoid creating new instances for default options.
*/
const EMPTY_OBJECT = {};
/**
* Vine Validator exposes the API to validate data using a pre-compiled
* schema. This class provides high-performance validation by compiling
* schemas once and reusing them for multiple validations.
*
* @template Schema - The schema type being validated
* @template MetaData - The metadata type passed to validation
*
* @example
* const validator = vine.compile(schema)
* const result = await validator.validate(data)
*/
var VineValidator = class {
	/**
	* Reference to the compiled schema containing the validation tree
	* and references for reuse during validation
	*/
	#compiled;
	/**
	* JSON Schema is only computed when asked.
	* We cache it in validator for reusability.
	*/
	#jsonSchema;
	/**
	* Messages provider instance used for internationalization
	* and custom error message formatting
	*/
	"messagesProvider";
	/**
	* Error reporter factory function used for formatting
	* and collecting validation errors
	*/
	"errorReporter";
	/**
	* Parses schema to compiler nodes for optimization and compilation.
	* This internal method converts the schema into an AST representation
	* that can be efficiently compiled into validation functions.
	*
	* @param schema - The schema to parse
	*/
	#parse(schema) {
		const refs = refsBuilder();
		return {
			compilerNode: {
				type: "root",
				schema: schema[PARSE]("", refs, { toCamelCase: false })
			},
			refs: refs.toJSON()
		};
	}
	/**
	* Creates a new VineValidator instance with a compiled schema.
	*
	* @param schema - The schema to compile for validation
	* @param options - Configuration options for the validator
	* @param options.convertEmptyStringsToNull - Whether to convert empty strings to null
	* @param options.metaDataValidator - Optional metadata validator function
	* @param options.messagesProvider - Messages provider for error formatting
	* @param options.errorReporter - Error reporter factory function
	*/
	"constructor"(schema, options) {
		this.schema = schema;
		this.options = options;
		/**
		* Compile the schema to a re-usable function
		*/
		const { compilerNode, refs } = this.#parse(schema);
		this.#compiled = {
			schema: compilerNode,
			refs
		};
		const metaDataValidator = options.metaDataValidator;
		const validateFn = new Compiler(compilerNode, {
			convertEmptyStringsToNull: options.convertEmptyStringsToNull,
			messages: COMPILER_ERROR_MESSAGES
		}).compile();
		/**
		* Assign error reporter and messages provider to public
		* properties so that they can be overridden at the
		* validator level.
		*/
		this.errorReporter = options.errorReporter;
		this.messagesProvider = options.messagesProvider;
		/**
		* Creating specialized functions with and without the
		* metadata validator to optimize the runtime
		* performance.
		*/
		if (metaDataValidator) this.validate = (data, validateOptions) => {
			let normalizedOptions = validateOptions ?? EMPTY_OBJECT;
			const meta = normalizedOptions.meta ?? {};
			const errorReporter = normalizedOptions.errorReporter ?? this.errorReporter;
			const messagesProvider = normalizedOptions.messagesProvider ?? this.messagesProvider;
			metaDataValidator(meta);
			return validateFn(data, meta, refs, messagesProvider, errorReporter());
		};
		else this.validate = (data, validateOptions) => {
			let normalizedOptions = validateOptions ?? EMPTY_OBJECT;
			const meta = normalizedOptions.meta ?? {};
			const errorReporter = normalizedOptions.errorReporter ?? this.errorReporter;
			return validateFn(data, meta, refs, normalizedOptions.messagesProvider ?? this.messagesProvider, errorReporter());
		};
	}
	/**
	* Performs validation without throwing a ValidationError exception.
	* Instead, returns a tuple where the first element is the error (if any)
	* and the second is the validated data (if successful).
	*
	* @param data - The data to validate
	* @param options - Optional validation options including metadata, custom error reporter, and messages provider
	*
	* @example
	* const [error, result] = await validator.tryValidate(data)
	* if (error) {
	*   console.log(error.messages)
	* } else {
	*   console.log(result)
	* }
	*
	* @example
	* // With metadata
	* const [error, result] = await validator.tryValidate(data, {
	*   meta: { userId: '123' }
	* })
	*
	* @example
	* // With custom error reporter
	* const [error, result] = await validator.tryValidate(data, {
	*   meta: { userId: auth.user.id },
	*   errorReporter: () => new CustomErrorReporter(),
	*   messagesProvider: customMessagesProvider
	* })
	*/
	async "tryValidate"(data, ...[options]) {
		try {
			return [null, await this.validate(data, options)];
		} catch (error) {
			if (error instanceof ValidationError) return [error, null];
			throw error;
		}
	}
	/**
	* Returns the compiled schema and refs as a JSON-serializable object.
	* Useful for caching compiled schemas or debugging validation logic.
	*
	* @example
	* const compiled = validator.toJSON()
	* console.log(compiled.schema)
	* console.log(compiled.refs)
	*/
	"toJSON"() {
		const { schema, refs } = this.#compiled;
		return {
			schema: structuredClone(schema),
			refs
		};
	}
	/**
	* Converts the validator's schema to JSON Schema Draft 7 format.
	* The result is cached for subsequent calls.
	*
	* @example
	* const jsonSchema = validator.toJSONSchema()
	* console.log(JSON.stringify(jsonSchema, null, 2))
	*/
	"toJSONSchema"() {
		if (!this.#jsonSchema) this.#jsonSchema = this.schema.toJSONSchema();
		return this.#jsonSchema;
	}
	/**
	* Standard Schema V1 compliance implementation.
	* Provides interoperability with other validation libraries through the
	* Standard Schema specification.
	*
	* @see https://github.com/standard-schema/standard-schema
	*/
	"~standard" = {
		version: 1,
		vendor: "vinejs",
		jsonSchema: {
			input: () => {
				return this.toJSONSchema();
			},
			output: () => {
				throw new Error("Vine.js does not support creating validators using JSON Schema.");
			}
		},
		validate: async (data) => {
			const [error, result] = await this.tryValidate(data, {});
			if (result) return { value: result };
			return { issues: error?.messages.map((message) => {
				return {
					...message,
					path: message.field
				};
			}) };
		}
	};
};
//#endregion
//#region src/vine/main.ts
/**
* Main Vine class that provides a fluent API for creating validation schemas
* and validating user input with type-safety using pre-compiled schemas.
*
* @example
* const vine = new Vine()
* const schema = vine.object({
*   name: vine.string(),
*   age: vine.number()
* })
* const result = await vine.validate({ schema, data: { name: 'John', age: 30 } })
*/
var Vine = class extends SchemaBuilder {
	/**
	* Messages provider to use on the validator for internationalization
	* and custom error message formatting
	*/
	messagesProvider = new SimpleMessagesProvider(messages, fields);
	/**
	* Error reporter factory function to use on the validator for
	* formatting validation errors
	*/
	errorReporter = () => new SimpleErrorReporter();
	/**
	* Control whether or not to convert empty strings to null during validation.
	* Useful for HTML form handling where empty inputs are submitted as empty strings
	*/
	convertEmptyStringsToNull = false;
	/**
	* Collection of helper functions to perform type-checking or cast types
	* while keeping HTML forms serialization behavior in mind
	*/
	helpers = helpers;
	/**
	* Utility function to convert a validation function to a Vine schema rule
	*/
	createRule = createRule;
	/**
	* Pre-compiles a schema into a validation function for better performance
	* when validating multiple data sets against the same schema.
	*
	* @param schema - The validation schema to compile
	*
	* @deprecated Instead use "create"
	*
	* @example
	* const schema = vine.object({
	*   name: vine.string(),
	*   age: vine.number()
	* })
	*
	* const validate = vine.compile(schema)
	* await validate.validate({ name: 'John', age: 30 })
	*/
	compile(schema) {
		return new VineValidator(schema, {
			convertEmptyStringsToNull: this.convertEmptyStringsToNull,
			messagesProvider: this.messagesProvider,
			errorReporter: this.errorReporter
		});
	}
	/**
	* Internal implementation that handles both schema and properties overloads.
	*/
	create(schemaOrProperties) {
		const validatorOptions = {
			convertEmptyStringsToNull: this.convertEmptyStringsToNull,
			messagesProvider: this.messagesProvider,
			errorReporter: this.errorReporter
		};
		if (PARSE in schemaOrProperties) return new VineValidator(schemaOrProperties, validatorOptions);
		return new VineValidator(new VineObject(schemaOrProperties), validatorOptions);
	}
	/**
	* Define a callback to validate the metadata given to the validator
	* at runtime. Useful for passing additional context like user IDs or permissions
	* that can be used within custom validation rules.
	*
	* @param callback - Optional validator function for metadata validation
	*
	* @example
	* // Without metadata validation
	* const validate = vine.withMetaData<{ userId: string }>().create({
	*   title: vine.string(),
	*   description: vine.string()
	* })
	*
	* await validate.validate(data, { meta: { userId: '123' } })
	*
	* @example
	* // With metadata validation
	* const validate = vine
	*   .withMetaData<{ userId: string }>((meta) => {
	*     if (!meta.userId) {
	*       throw new Error('userId is required in metadata')
	*     }
	*   })
	*   .create(schema)
	*
	* await validate.validate(data, { meta: { userId: '123' } })
	*/
	withMetaData(callback) {
		return {
			compile: (schema) => {
				return new VineValidator(schema, {
					convertEmptyStringsToNull: this.convertEmptyStringsToNull,
					messagesProvider: this.messagesProvider,
					errorReporter: this.errorReporter,
					metaDataValidator: callback
				});
			},
			create: (schemaOrProperties) => {
				const validatorOptions = {
					convertEmptyStringsToNull: this.convertEmptyStringsToNull,
					messagesProvider: this.messagesProvider,
					errorReporter: this.errorReporter,
					metaDataValidator: callback
				};
				if (PARSE in schemaOrProperties) return new VineValidator(schemaOrProperties, validatorOptions);
				return new VineValidator(new VineObject(schemaOrProperties), validatorOptions);
			}
		};
	}
	/**
	* Validate data against a schema. Optionally, you can define
	* error messages, fields, a custom messages provider,
	* or an error reporter.
	*
	* @param options - Configuration object containing schema, data, and validation options
	* @returns Promise resolving to validated and typed data
	* @throws {ValidationError} When validation fails
	*
	* @example
	* await vine.validate({ schema, data })
	* await vine.validate({ schema, data, messages, fields })
	*
	* await vine.validate({ schema, data, messages, fields }, {
	*   errorReporter
	* })
	*/
	validate(options) {
		return this.compile(options.schema).validate(options.data, options);
	}
	/**
	* Validate data against a schema without throwing the
	* "ValidationError" exception. Instead the validation
	* errors are returned within the return value.
	*
	* @param options - Configuration object containing schema, data, and validation options
	* @returns Promise resolving to tuple of [error, null] or [null, validatedData]
	*
	* @example
	* await vine.tryValidate({ schema, data })
	* await vine.tryValidate({ schema, data, messages, fields })
	*
	* await vine.tryValidate({ schema, data, messages, fields }, {
	*   errorReporter
	* })
	*/
	tryValidate(options) {
		return this.compile(options.schema).tryValidate(options.data, options);
	}
};
//#endregion
//#region index.ts
const vine = new Vine();
//#endregion
export { BaseLiteralType, BaseType, ConditionalValidations, MetaModifier, NullableModifier, OptionalModifier, SimpleErrorReporter, SimpleMessagesProvider, UnionConditional, ValidationError, Vine, VineAccepted, VineAny, VineArray, VineBoolean, VineDate, VineEnum, VineLiteral, VineNativeEnum, VineNativeFile, VineNull, VineNumber, VineObject, VineOptional, VineRecord, VineString, VineTuple, VineUnion, VineValidator, vine as default, main_exports as errors, requiredWhen, symbols_exports as symbols };
