UNPKG

2.45 kBTypeScriptView Raw
1import { Predicate, PredicateOptions } from './predicate';
2export declare class StringPredicate extends Predicate<string> {
3 /**
4 @hidden
5 */
6 constructor(options?: PredicateOptions);
7 /**
8 Test a string to have a specific length.
9
10 @param length - The length of the string.
11 */
12 length(length: number): this;
13 /**
14 Test a string to have a minimum length.
15
16 @param length - The minimum length of the string.
17 */
18 minLength(length: number): this;
19 /**
20 Test a string to have a maximum length.
21
22 @param length - The maximum length of the string.
23 */
24 maxLength(length: number): this;
25 /**
26 Test a string against a regular expression.
27
28 @param regex - The regular expression to match the value with.
29 */
30 matches(regex: RegExp): this;
31 /**
32 Test a string to start with a specific value.
33
34 @param searchString - The value that should be the start of the string.
35 */
36 startsWith(searchString: string): this;
37 /**
38 Test a string to end with a specific value.
39
40 @param searchString - The value that should be the end of the string.
41 */
42 endsWith(searchString: string): this;
43 /**
44 Test a string to include a specific value.
45
46 @param searchString - The value that should be included in the string.
47 */
48 includes(searchString: string): this;
49 /**
50 Test if the string is an element of the provided list.
51
52 @param list - List of possible values.
53 */
54 oneOf(list: readonly string[]): this;
55 /**
56 Test a string to be empty.
57 */
58 get empty(): this;
59 /**
60 Test a string to be not empty.
61 */
62 get nonEmpty(): this;
63 /**
64 Test a string to be equal to a specified string.
65
66 @param expected - Expected value to match.
67 */
68 equals(expected: string): this;
69 /**
70 Test a string to be alphanumeric.
71 */
72 get alphanumeric(): this;
73 /**
74 Test a string to be alphabetical.
75 */
76 get alphabetical(): this;
77 /**
78 Test a string to be numeric.
79 */
80 get numeric(): this;
81 /**
82 Test a string to be a valid date.
83 */
84 get date(): this;
85 /**
86 Test a non-empty string to be lowercase. Matching both alphabetical & numbers.
87 */
88 get lowercase(): this;
89 /**
90 Test a non-empty string to be uppercase. Matching both alphabetical & numbers.
91 */
92 get uppercase(): this;
93 /**
94 Test a string to be a valid URL.
95 */
96 get url(): this;
97}