You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: config/core/index.ts
+24-9Lines changed: 24 additions & 9 deletions
Original file line number
Diff line number
Diff line change
@@ -1,5 +1,5 @@
1
1
import{
2
-
_enum,
2
+
path,
3
3
domain,
4
4
email,
5
5
endpoint,
@@ -30,11 +30,13 @@ export type SafeParseReturnType<T> =
30
30
classStringBuilder{
31
31
readonly #validators: Validator<string>[]=[];
32
32
33
-
enum(inputs: string[]): this {
34
-
this.#validators.push(_enum(inputs));
35
-
returnthis;
36
-
}
37
-
33
+
/**
34
+
* Adds a validator that checks if the string is not empty.
35
+
*
36
+
* This validator will fail if the string is `undefined`, `null`, or an empty string.
37
+
*
38
+
* This validator is meant to be used when there are no other validations being used, since all other validations have null/undefined/"" checks in them.
39
+
*/
38
40
notEmpty(): this {
39
41
this.#validators.push(notEmpty());
40
42
returnthis;
@@ -105,18 +107,31 @@ class StringBuilder {
105
107
returnthis;
106
108
}
107
109
108
-
// --
110
+
path(): this {
111
+
this.#validators.push(path());
112
+
returnthis;
113
+
}
109
114
115
+
/**
116
+
* Adds a validator that allows the string to be optional.
117
+
*
118
+
* This validator prevent failure if the string is undefined.
119
+
*
120
+
* This is useful when you want to validate something that you know it can or can't be there,
121
+
* adding other validators on top to validate when there actually is something.
0 commit comments