UNPKG

regexp-toolkit

Version:
57 lines (53 loc) 1.73 kB
declare class RegexBuilder { private pattern; digit(): this; letter(): this; lowercase(): this; uppercase(): this; lettersOrNumbers(): this; whitespace(): this; nonWhitespace(): this; wordChar(): this; nonWordChar(): this; anyChar(): this; custom(chars: string): this; one(): this; zeroOrMore(): this; oneOrMore(): this; optional(): this; between(min: number, max: number): this; exactly(n: number): this; atLeast(n: number): this; start(): this; end(): this; strict(): this; group(fn: (builder: RegexBuilder) => void): this; capture(fn: (builder: RegexBuilder) => void): this; or(): this; then(str: string): this; raw(str: string): this; not(str: string): this; lookahead(str: string): this; toRegex(flags?: string): RegExp; toString(): string; test(input: string): boolean; match(input: string): RegExpMatchArray | null; } declare const validators: { readonly email: (val: string) => boolean; readonly phone: (val: string) => boolean; readonly url: (val: string) => boolean; readonly ipv4: (val: string) => boolean; readonly hex: (val: string) => boolean; readonly username: (val: string) => boolean; readonly password: (val: string) => boolean; readonly slug: (val: string) => boolean; readonly date: (val: string) => boolean; readonly time: (val: string) => boolean; readonly uuid: (val: string) => boolean; readonly htmlTag: (val: string) => boolean; }; type ValidatorKey = keyof typeof validators; declare function regex(): RegexBuilder; declare function validate(type: ValidatorKey, value: string): boolean; export { regex, validate };