import type { Validator } from '@stacksjs/ts-validation'; export declare function isObjectNotEmpty(obj: object | undefined): boolean; export declare function validateField(modelFile: string, params: RequestData): Promise; /** * Register a custom validation rule that can be referenced by name. */ export declare function registerRule(name: string, rule: AsyncValidator): void; /** * Get a registered custom rule by name. */ export declare function getCustomRule(name: string): AsyncValidator | undefined; /** * Built-in async rule: checks that a value is unique in a database table. */ export declare function unique(table: string, column: string, exceptId?: number): AsyncValidator; /** * Built-in async rule: checks that a value exists in a database table. */ export declare function exists(table: string, column: string): AsyncValidator; /** * Validate fields with both sync rules (from model) and async rules. * Runs sync validation first, then async rules, combining all errors. */ export declare function validateFieldAsync(modelFile: string, params: RequestData, asyncRules?: Record): Promise; /** * Action-side validation shortcut. Returns the validated input typed as * `T` so callers can drop the post-validate type-cast they used to need. * * Throws `HttpError(422, 'Validation failed', { errors })` on the first * failing field — the router's error handler turns that into a JSON * 422 response automatically. * * @example * ```ts * import { validate, schema } from '@stacksjs/validation' * * type Payload = { email: string; age: number } * * const data = await validate(req, { * email: schema.string().email(), * age: schema.number().min(0), * }) * * // `data.email` is `string`, `data.age` is `number` — no cast needed. * ``` */ export declare function validate>(request: RequestLike | Record, rules: ValidationRules): Promise; export declare function customValidate(attributes: CustomAttributes, params: RequestData): Promise; declare interface RequestData { [key: string]: any } declare interface ValidationField { rule: ValidationType message: Record } declare interface CustomAttributes { [key: string]: ValidationField } declare interface RequestLike { all?: () => Record | Promise> jsonBody?: Record formBody?: Record query?: Record params?: Record url?: string } /** * Async validation rule type. * Return true if valid, or a string error message if invalid. */ // eslint-disable-next-line pickier/no-unused-vars export type AsyncValidator = (value: unknown, params: RequestData) => Promise; /** * Shape of a validation rule set understood by `validate()`. Each key * maps to either a raw `Validator` (from `@stacksjs/ts-validation`) * or a `{ rule, message }` object that mirrors the model-attribute form. */ export type ValidationRules = Record | { rule: Validator, message?: string | Record }>;