helping-js
Version:
helping-js: zero-dependency JavaScript utilities — type guards, 50+ regex patterns, validate(), TypeScript .d.ts, v3 helpers (string, array, object, async, date, URL, tree, DOM). Official docs: https://helping-js.netlify.app
15 lines (12 loc) • 343 B
TypeScript
export type Rule = RegExp | ((value: unknown) => boolean);
export interface ValidateResult {
valid: boolean;
errors: Record<string, boolean>;
}
/**
* Validate an object against a map of rules (RegExp or predicate function).
*/
export function validate(
data: Record<string, unknown>,
rules: Record<string, Rule>
): ValidateResult;