@quenk/preconditions
Version:
Make data satisfy constraints before using.
50 lines (49 loc) • 1.55 kB
TypeScript
import { Type } from '@quenk/noni/lib/data/type';
import { Precondition } from './';
/**
* matches tests if the value satisfies a regular expression.
*/
export declare const matches: (pattern: RegExp | string) => Precondition<string, string>;
export { matches as pattern };
/**
* maxLength test.
*/
export declare const maxLength: (target: number) => Precondition<string, string>;
/**
* minLength test.
*/
export declare const minLength: (target: number) => Precondition<string, string>;
/**
* range tests whether the length of string falls within a range.
*/
export declare const range: (min: number, max: number) => Precondition<string, string>;
/**
* uppercase transforms a string into uppercase
*/
export declare const uppercase: Precondition<string, string>;
export declare const upper: Precondition<string, string>;
/**
* lowercase transforms a string into lowercase
*/
export declare const lowercase: Precondition<string, string>;
export declare const lower: Precondition<string, string>;
/**
* trim the whitespace from a string.
*/
export declare const trim: Precondition<string, string>;
/**
* split a string into an array.
*/
export declare const split: (token: string) => Precondition<string, string[]>;
/**
* nonEmpty rejects empty strings.
*/
export declare const nonEmpty: Precondition<string, string>;
/**
* isString tests if a value is a string.
*/
export declare const isString: Precondition<Type, string>;
/**
* toString casts a value into a string.
*/
export declare const toString: Precondition<Type, string>;