simple-body-validator
Version:
This package is inspired by Laravel validation, and aims to make body validation easier for Javascript developers
58 lines (57 loc) • 1.89 kB
TypeScript
import { Rule } from '../types';
/**
* Get the size of a value based on its type
*/
export declare function getSize(value: any, hasNumericRule?: boolean): number;
/**
* Check if two values are of the same type
*/
export declare function sameType(value: any, otherValue: any): boolean;
/**
* Check if Value is an Ineteger
*/
export declare function isInteger(value: any): boolean;
/**
* Check if the value can be considered as rule
*/
export declare function isRule(value: any): boolean;
/**
* Check if the array contain any potentiel valid rule
*/
export declare function isArrayOfRules(values: any[]): boolean;
/**
* Check if the rule is related to size
*/
export declare function isSizeRule(rule: string): boolean;
/**
* Check if rule implies that the field is required
*/
export declare function isImplicitRule(rule: Rule): boolean;
/**
* Add a new implicit rule
*/
export declare function addImplicitRule(rule: string): void;
/**
* Returns the numeric rules
*/
export declare function getNumericRules(): string[];
/**
* Check if the rule is numeric
*/
export declare function isNumericRule(rule: string): boolean;
/**
* Determine if a comparison passes between the given values.
*/
export declare function compare(first: any, second: any, operator: string, strict?: boolean): boolean;
/**
* Convert the given values to boolean if they are string "true" / "false".
*/
export declare function convertValuesToBoolean(values: string[]): (string | boolean)[];
/**
* Convert the given values to numbers if they are numbers in a string "1", "2"
*/
export declare function convertValuesToNumber(values: string[]): (string | number)[];
/**
* Convert the given values to null if they have null values in a string "null", "NULL"
*/
export declare function convertValuesToNull(values: string[]): (string | null)[];