UNPKG

2.56 kBTypeScriptView Raw
1import { Predicate, type PredicateOptions } from './predicate.js';
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 contain at least 1 non-whitespace character.
61 */
62 get nonBlank(): this;
63 /**
64 Test a string to be not empty.
65 */
66 get nonEmpty(): this;
67 /**
68 Test a string to be equal to a specified string.
69
70 @param expected - Expected value to match.
71 */
72 equals(expected: string): this;
73 /**
74 Test a string to be alphanumeric.
75 */
76 get alphanumeric(): this;
77 /**
78 Test a string to be alphabetical.
79 */
80 get alphabetical(): this;
81 /**
82 Test a string to be numeric.
83 */
84 get numeric(): this;
85 /**
86 Test a string to be a valid date.
87 */
88 get date(): this;
89 /**
90 Test a non-empty string to be lowercase. Matching both alphabetical & numbers.
91 */
92 get lowercase(): this;
93 /**
94 Test a non-empty string to be uppercase. Matching both alphabetical & numbers.
95 */
96 get uppercase(): this;
97 /**
98 Test a string to be a valid URL.
99 */
100 get url(): this;
101}