@codeparticle/formal
Version:
A <2kb library for validating data of any kind
22 lines (19 loc) • 756 B
TypeScript
import { ValidationRule, CustomValidatorOptions, ValidationCheck } from './types/index.js';
declare class Rule implements ValidationRule {
message: string | ((v: any) => string);
opts: CustomValidatorOptions;
constructor(opts: CustomValidatorOptions);
check: ValidationCheck;
}
/**
* Exposed interface to create a rule
*/
declare const createRule: (opts: CustomValidatorOptions) => ValidationRule;
/**
* Method to overwrite the message of a rule.
* Useful if you'd like to use a built-in, but want to change the ultimate message
* that comes out of a failed check.
* @param message
*/
declare const withMessage: (message: string | ((v?: any) => string)) => (rule: ValidationRule) => Rule;
export { Rule, createRule, withMessage };