UNPKG

@codeparticle/formal

Version:

A <2kb library for validating data of any kind

27 lines (24 loc) 882 B
import { ValidationRuleset, ValidationM, ValidationActions } from './types/index.js'; /** * convenience method to generate a Success or Fail with a custom message (or message function), * based on the passing of a supplied condition * */ declare class Validator implements Validator { static of(...rules: ValidationRuleset): Validator; rules: ValidationRuleset; result: ValidationM | null; constructor(...rules: ValidationRuleset); /** * Run all of the supplied validators against the value that Validator() was supplied with, * then operate on the results based on whether this succeeded or failed. * @param {Object} opts * @property {Function} onSuccess * @property {Function} onFail * * @returns {Any} result */ validate(value: any): Validator; then(opts: ValidationActions): any; } export { Validator };