aptx-validator
Version:
轻量易用的 Node.js + Typescript 参数校验库
36 lines (35 loc) • 1.45 kB
TypeScript
import { IUtils, UtilFunction } from './types';
declare class Utils implements IUtils {
number(): (v: any) => boolean;
isNaN(): (v: any) => boolean;
boolean(): (v: any) => boolean;
string(): (v: any) => boolean;
array(): (v: any) => boolean;
object(): (v: any) => boolean;
bigInt(): (v: any) => boolean;
oneof(arr: any[]): (v: any) => boolean;
min(min: number): (v: number) => boolean;
max(max: number): (v: number) => boolean;
int(): (v: number) => boolean;
positive(): (v: number) => boolean;
negative(): (v: number) => boolean;
id(): (v: number) => boolean;
minLength(min: number): (v: string | typeof Array) => boolean;
maxLength(max: number): (v: string | typeof Array) => boolean;
toFixed(length: number): (v: number | string) => boolean;
numeric(): (v: string) => boolean;
useRE(re: RegExp): (v: string) => boolean;
email(emailRE?: RegExp): (v: string) => boolean;
phone(phoneRE?: RegExp): (v: string) => boolean;
date(datePatterns: string[]): (v: string) => boolean;
booleanStr(): (v: string) => v is "false" | "true";
resetFunction(name: keyof Utils, fn: UtilFunction): void;
}
/**
* @param {*} v
* @returns {boolean} true if the value is undefined or null or NaN
*/
export declare const isEmptyValue: (v: any) => boolean;
declare const _default: Utils;
export default _default;
export declare const DEFAULT_ERROR_TEXT = "validation error";