/** Result of a single field validation run */ type ValidationStatus = "Valid" | "Invalid" | "NotValidated"; /** Input passed to every validator's validate() method */ interface ValidatorInput { /** Current value of the field element */ value: string; /** Options configured by the user for this validator (e.g. { message, min, max }) */ options: Record; /** Name of the field being validated */ field: string; /** All DOM elements associated with the field */ elements: HTMLElement[]; /** The form element */ form: HTMLFormElement; } /** What a validator's validate() method returns */ interface ValidatorResult { valid: boolean; /** If provided, overrides the message from locale/options */ message?: string; /** Extra data returned by the validator (e.g. detected credit card type) */ meta?: Record; } /** The object returned by a ValidatorFactory */ interface ValidatorObject { validate(input: ValidatorInput): ValidatorResult | Promise; } /** A validator is a zero-argument factory that returns a ValidatorObject */ type ValidatorFactory = () => ValidatorObject; /** Per-validator config inside a field definition */ interface ValidatorOptions { /** Custom error message — overrides locale */ message?: string; /** Set to false to disable this validator without removing it */ enabled?: boolean; [key: string]: unknown; } /** Field definition passed to validare() or addField() */ interface FieldOptions { /** CSS selector to find the field elements. Defaults to [name="fieldName"] */ selector?: string; /** Map of validator name → validator options */ validators: Record; } /** Locale data: map of validatorName → { default: 'message', ... } */ type LocaleData = Record>; /** Payload for core.element.validated event */ interface ElementValidatedPayload { field: string; element: HTMLElement; elements: HTMLElement[]; valid: boolean; result: ValidationStatus; /** Per-validator results for this element */ validators: Record; } export type { ElementValidatedPayload as E, FieldOptions as F, LocaleData as L, ValidationStatus as V, ValidatorFactory as a, ValidatorInput as b, ValidatorObject as c, ValidatorOptions as d, ValidatorResult as e };