UNPKG

@ents24/be-sure

Version:

NPM module for terse, 'throwy' validation

22 lines (21 loc) 1.21 kB
import { BeSureKey } from './validators'; /** * Find a validator that matches `key`, run it with the passed `value`, throw on failure * @param {Mixed} value the value to check * @param {String} key the validator key to check against * @param {any} errorType a type that extends Error * @param {String | undefined} errorText the text to include if an error is thrown * @throws A validator matching the passed key must exist and return true */ export declare function beSure(value: any, key: BeSureKey, errorType?: any, errorText?: string): void; /** * Find a validator that matches `key`, run it with the passed `value`, throw on failure * Never throw on `null` value * @param {Mixed} value the value to check * @param {String} key the validator key to check against * @param {any} errorType a type that extends Error * @param {String | undefined} errorText the text to include if an error is thrown * @throws A validator matching the passed key must exist and return true */ export declare function beSureAllowNull(value: any, key: BeSureKey, errorType?: any, errorText?: string): void; export declare function beSureCustom(value: any, customKey: string, errorType?: any, errorText?: string): void;