/** * adowire — WireValidator * * Validation engine that executes VineJS rules against component property * values. Used by the request handler's `maybeValidateOnUpdate()` flow and * by `WireComponent.validate()` to run per-property or batch validation. * * Like Livewire, `validate()` returns the **validated data** — the * cleaned/coerced values produced by the validator (e.g. trimmed strings, * coerced booleans, transformed values). Callers should use the returned * data rather than reading properties directly, so that VineJS * transformations are honoured. * * VineJS is a **peer dependency** — it is imported dynamically from the * consuming application's `node_modules` (resolved via `process.cwd()`) * so the adowire package itself does not hard-depend on it. * * @module */ export interface ValidatePropertyOpts { /** Override the default VineJS error message with a custom one. */ message?: string; /** Display label passed to VineJS as the human-readable field name. */ as?: string; } /** * Result of validating a single property. * * - `errors` — array of error messages (empty when valid). * - `value` — the validated/coerced value produced by VineJS. When * validation fails this is `undefined`. */ export interface PropertyValidationResult { errors: string[]; value: any; } /** * Result of validating multiple properties in one pass. * * - `errors` — `Record` matching the `$errors` shape. * Only properties that failed are included. * - `validated` — `Record` of cleaned/coerced values for * properties that **passed** validation. */ export interface BatchValidationResult { errors: Record; validated: Record; } export declare class WireValidator { /** * Validate a single property value against its VineJS rule. * * Returns a `PropertyValidationResult` containing both the error messages * (empty array when valid) and the validated/coerced value produced by * VineJS. This allows callers to use the cleaned value — e.g. trimmed * strings, coerced booleans, transformed values — rather than the raw * input, matching Livewire's `$validated = $this->validate()` semantics. * * This method never throws; validation failures are captured and returned. * * @param property The property name (used as the schema field key). * @param value The current value to validate. * @param rule A VineJS rule (e.g. `vine.string().minLength(3)`). * @param opts Optional overrides for message / display label. */ static validateProperty(property: string, value: any, rule: any, opts?: ValidatePropertyOpts): Promise; /** * Validate multiple properties in one pass. * * Accepts a record keyed by property name, each entry containing the * current `value`, the VineJS `rule`, and optional `opts`. * * Returns a `BatchValidationResult` with: * - `errors` — `Record` for failed properties only. * - `validated` — `Record` of cleaned/coerced values for * properties that passed. * * @param properties Map of property → { value, rule, opts? } */ static validateProperties(properties: Record): Promise; /** * Extract human-readable error messages from a VineJS validation error. * * VineJS throws an error whose `.messages` property is an array of * `{ field: string; message: string; rule: string; … }` objects. We * collect the `message` strings for the given property. * * When the caller provides a `message` override in `opts`, **all** * VineJS messages for that field are replaced with the single override. * * @internal */ private static extractMessages; }