validatorshield
Version:
Universal validation (frontend + backend) with TypeScript. Includes common rules and Sequelize-backed async rules (unique, exists).
10 lines (9 loc) • 356 B
TypeScript
export type RuleContext = {
field: string;
data: Record<string, any>;
};
export type RuleFunction = (value: any, ctx: RuleContext, ...args: string[]) => boolean | Promise<boolean>;
export declare function validate(data: Record<string, any>, rules: Record<string, string[]>): Promise<{
passed: boolean;
errors: Record<string, string[]>;
}>;