cerceis-lib
Version:
Contains list of quality of life functions that is written in TypeScript and es6
48 lines (46 loc) • 1.51 kB
TypeScript
interface ValidationError {
errored: unknown;
code: string;
label?: string;
}
type Locale = "en" | "ja";
declare class Validator {
private locale;
inputValue: unknown;
private currentErrorName;
errorMap: Record<string, ValidationError[]>;
private pristineMap;
private valueMap;
setLocale(locale: Locale): void;
value(inputValue: unknown): this;
/**
* Name the current value for grouping errors in errorMap.
* Must be chained after value().
*/
as(inputName: string): this;
private _addError;
static isDefined: (x: unknown) => boolean;
static isUndefined: (x: unknown) => boolean;
static isArray: (arg: any) => arg is any[];
static isString: (x: unknown) => boolean;
static isObject: (x: unknown) => boolean;
static isNumber: (x: unknown) => boolean;
static isBoolean: (x: unknown) => boolean;
/**
* Check minimum length (strings/arrays) or minimum value (numbers).
* Does not check for null/undefined — use required() for that.
*/
min(min: number): this;
max(max: number): this;
isEmail(): this;
required(): this;
alphanumeric(): this;
noSpecials(space?: boolean, extendJpn?: boolean | null): this;
isUUIDv4(): this;
isSameAs(value: unknown): this;
verify(returnErrors?: boolean): boolean | Record<string, ValidationError[]>;
hasError(): boolean;
reset(): void;
}
declare const validator: Validator;
export { type Locale, Validator, validator };