@nr1e/commons 0.0.3-alpha.15 → 0.0.3-alpha.16
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bitsnbytes/b64.d.ts +39 -0
- package/bitsnbytes/b64.js +130 -0
- package/bitsnbytes/b64.js.map +1 -0
- package/bitsnbytes/index.d.ts +1 -0
- package/bitsnbytes/index.js +2 -0
- package/bitsnbytes/index.js.map +1 -0
- package/errors/errors.d.ts +160 -0
- package/errors/errors.js +230 -0
- package/errors/errors.js.map +1 -0
- package/errors/index.d.ts +1 -0
- package/errors/index.js +2 -0
- package/errors/index.js.map +1 -0
- package/http/http-method.d.ts +9 -0
- package/http/http-method.js +11 -0
- package/http/http-method.js.map +1 -0
- package/http/http-status-code.d.ts +42 -0
- package/http/http-status-code.js +44 -0
- package/http/http-status-code.js.map +1 -0
- package/http/index.d.ts +2 -0
- package/http/index.js +3 -0
- package/http/index.js.map +1 -0
- package/lang/index.d.ts +2 -0
- package/lang/index.js +3 -0
- package/lang/index.js.map +1 -0
- package/lang/sleep.d.ts +6 -0
- package/lang/sleep.js +9 -0
- package/lang/sleep.js.map +1 -0
- package/lang/type-functions.d.ts +3 -0
- package/lang/type-functions.js +10 -0
- package/lang/type-functions.js.map +1 -0
- package/package.json +2 -5
- package/validator/index.d.ts +1 -0
- package/validator/index.js +2 -0
- package/validator/index.js.map +1 -0
- package/validator/validators.d.ts +188 -0
- package/validator/validators.js +302 -0
- package/validator/validators.js.map +1 -0
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
export var HttpStatusCode;
|
|
2
|
+
(function (HttpStatusCode) {
|
|
3
|
+
HttpStatusCode[HttpStatusCode["CONTINUE"] = 100] = "CONTINUE";
|
|
4
|
+
HttpStatusCode[HttpStatusCode["SWITCHING_PROTOCOLS"] = 101] = "SWITCHING_PROTOCOLS";
|
|
5
|
+
HttpStatusCode[HttpStatusCode["OK"] = 200] = "OK";
|
|
6
|
+
HttpStatusCode[HttpStatusCode["CREATED"] = 201] = "CREATED";
|
|
7
|
+
HttpStatusCode[HttpStatusCode["ACCEPTED"] = 202] = "ACCEPTED";
|
|
8
|
+
HttpStatusCode[HttpStatusCode["NON_AUTHORITATIVE_INFORMATION"] = 203] = "NON_AUTHORITATIVE_INFORMATION";
|
|
9
|
+
HttpStatusCode[HttpStatusCode["NO_CONTENT"] = 204] = "NO_CONTENT";
|
|
10
|
+
HttpStatusCode[HttpStatusCode["RESET_CONTENT"] = 205] = "RESET_CONTENT";
|
|
11
|
+
HttpStatusCode[HttpStatusCode["PARTIAL_CONTENT"] = 206] = "PARTIAL_CONTENT";
|
|
12
|
+
HttpStatusCode[HttpStatusCode["MULTIPLE_CHOICES"] = 300] = "MULTIPLE_CHOICES";
|
|
13
|
+
HttpStatusCode[HttpStatusCode["PERMANENT_REDIRECT"] = 301] = "PERMANENT_REDIRECT";
|
|
14
|
+
HttpStatusCode[HttpStatusCode["FOUND"] = 302] = "FOUND";
|
|
15
|
+
HttpStatusCode[HttpStatusCode["SEE_OTHER"] = 303] = "SEE_OTHER";
|
|
16
|
+
HttpStatusCode[HttpStatusCode["NOT_MODIFIED"] = 304] = "NOT_MODIFIED";
|
|
17
|
+
HttpStatusCode[HttpStatusCode["USE_PROXY"] = 305] = "USE_PROXY";
|
|
18
|
+
HttpStatusCode[HttpStatusCode["TEMPORARY_REDIRECT"] = 307] = "TEMPORARY_REDIRECT";
|
|
19
|
+
HttpStatusCode[HttpStatusCode["BAD_REQUEST"] = 400] = "BAD_REQUEST";
|
|
20
|
+
HttpStatusCode[HttpStatusCode["UNAUTHORIZED"] = 401] = "UNAUTHORIZED";
|
|
21
|
+
HttpStatusCode[HttpStatusCode["PAYMENT_REQUIRED"] = 402] = "PAYMENT_REQUIRED";
|
|
22
|
+
HttpStatusCode[HttpStatusCode["FORBIDDEN"] = 403] = "FORBIDDEN";
|
|
23
|
+
HttpStatusCode[HttpStatusCode["NOT_FOUND"] = 404] = "NOT_FOUND";
|
|
24
|
+
HttpStatusCode[HttpStatusCode["METHOD_NOT_ALLOWED"] = 405] = "METHOD_NOT_ALLOWED";
|
|
25
|
+
HttpStatusCode[HttpStatusCode["NOT_ACCEPTABLE"] = 406] = "NOT_ACCEPTABLE";
|
|
26
|
+
HttpStatusCode[HttpStatusCode["PROXY_AUTHENTICATION_REQUIRED"] = 407] = "PROXY_AUTHENTICATION_REQUIRED";
|
|
27
|
+
HttpStatusCode[HttpStatusCode["REQUEST_TIMEOUT"] = 408] = "REQUEST_TIMEOUT";
|
|
28
|
+
HttpStatusCode[HttpStatusCode["CONFLICT"] = 409] = "CONFLICT";
|
|
29
|
+
HttpStatusCode[HttpStatusCode["GONE"] = 410] = "GONE";
|
|
30
|
+
HttpStatusCode[HttpStatusCode["LENGTH_REQUIRED"] = 411] = "LENGTH_REQUIRED";
|
|
31
|
+
HttpStatusCode[HttpStatusCode["PRECONDITION_FAILED"] = 412] = "PRECONDITION_FAILED";
|
|
32
|
+
HttpStatusCode[HttpStatusCode["REQUEST_ENTITY_TOO_LARGE"] = 413] = "REQUEST_ENTITY_TOO_LARGE";
|
|
33
|
+
HttpStatusCode[HttpStatusCode["REQUEST_URI_TOO_LONG"] = 414] = "REQUEST_URI_TOO_LONG";
|
|
34
|
+
HttpStatusCode[HttpStatusCode["UNSUPPORTED_MEDIA_TYPE"] = 415] = "UNSUPPORTED_MEDIA_TYPE";
|
|
35
|
+
HttpStatusCode[HttpStatusCode["RANGE_NOT_SATISFIABLE"] = 416] = "RANGE_NOT_SATISFIABLE";
|
|
36
|
+
HttpStatusCode[HttpStatusCode["EXPECTATION_FAILED"] = 417] = "EXPECTATION_FAILED";
|
|
37
|
+
HttpStatusCode[HttpStatusCode["INTERNAL_SERVER_ERROR"] = 500] = "INTERNAL_SERVER_ERROR";
|
|
38
|
+
HttpStatusCode[HttpStatusCode["NOT_IMPLEMENTED"] = 501] = "NOT_IMPLEMENTED";
|
|
39
|
+
HttpStatusCode[HttpStatusCode["BAD_GATEWAY"] = 502] = "BAD_GATEWAY";
|
|
40
|
+
HttpStatusCode[HttpStatusCode["SERVICE_UNAVAILABLE"] = 503] = "SERVICE_UNAVAILABLE";
|
|
41
|
+
HttpStatusCode[HttpStatusCode["GATEWAY_TIMEOUT"] = 504] = "GATEWAY_TIMEOUT";
|
|
42
|
+
HttpStatusCode[HttpStatusCode["HTTP_VERSION_NOT_SUPPORTED"] = 505] = "HTTP_VERSION_NOT_SUPPORTED";
|
|
43
|
+
})(HttpStatusCode || (HttpStatusCode = {}));
|
|
44
|
+
//# sourceMappingURL=http-status-code.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"http-status-code.js","sourceRoot":"","sources":["../../src/http/http-status-code.ts"],"names":[],"mappings":"AAAA,MAAM,CAAN,IAAY,cAyCX;AAzCD,WAAY,cAAc;IACxB,6DAAc,CAAA;IACd,mFAAyB,CAAA;IACzB,iDAAQ,CAAA;IACR,2DAAa,CAAA;IACb,6DAAc,CAAA;IACd,uGAAmC,CAAA;IACnC,iEAAgB,CAAA;IAChB,uEAAmB,CAAA;IACnB,2EAAqB,CAAA;IACrB,6EAAsB,CAAA;IACtB,iFAAwB,CAAA;IACxB,uDAAW,CAAA;IACX,+DAAe,CAAA;IACf,qEAAkB,CAAA;IAClB,+DAAe,CAAA;IACf,iFAAwB,CAAA;IACxB,mEAAiB,CAAA;IACjB,qEAAkB,CAAA;IAClB,6EAAsB,CAAA;IACtB,+DAAe,CAAA;IACf,+DAAe,CAAA;IACf,iFAAwB,CAAA;IACxB,yEAAoB,CAAA;IACpB,uGAAmC,CAAA;IACnC,2EAAqB,CAAA;IACrB,6DAAc,CAAA;IACd,qDAAU,CAAA;IACV,2EAAqB,CAAA;IACrB,mFAAyB,CAAA;IACzB,6FAA8B,CAAA;IAC9B,qFAA0B,CAAA;IAC1B,yFAA4B,CAAA;IAC5B,uFAA2B,CAAA;IAC3B,iFAAwB,CAAA;IACxB,uFAA2B,CAAA;IAC3B,2EAAqB,CAAA;IACrB,mEAAiB,CAAA;IACjB,mFAAyB,CAAA;IACzB,2EAAqB,CAAA;IACrB,iGAAgC,CAAA;AAClC,CAAC,EAzCW,cAAc,KAAd,cAAc,QAyCzB"}
|
package/http/index.d.ts
ADDED
package/http/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/http/index.ts"],"names":[],"mappings":"AAAA,cAAc,oBAAoB,CAAC;AACnC,cAAc,eAAe,CAAC"}
|
package/lang/index.d.ts
ADDED
package/lang/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/lang/index.ts"],"names":[],"mappings":"AAAA,cAAc,kBAAkB,CAAC;AACjC,cAAc,SAAS,CAAC"}
|
package/lang/sleep.d.ts
ADDED
package/lang/sleep.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sleep.js","sourceRoot":"","sources":["../../src/lang/sleep.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,MAAM,UAAU,KAAK,CAAC,EAAU;IAC9B,OAAO,IAAI,OAAO,CAAC,OAAO,CAAC,EAAE,CAAC,UAAU,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC,CAAC;AACzD,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export function isObject(item) {
|
|
2
|
+
return (item !== null && typeof item === 'object' && Array.isArray(item) === false);
|
|
3
|
+
}
|
|
4
|
+
export function isString(item) {
|
|
5
|
+
return typeof item === 'string';
|
|
6
|
+
}
|
|
7
|
+
export function isError(item) {
|
|
8
|
+
return item instanceof Error;
|
|
9
|
+
}
|
|
10
|
+
//# sourceMappingURL=type-functions.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"type-functions.js","sourceRoot":"","sources":["../../src/lang/type-functions.ts"],"names":[],"mappings":"AAAA,MAAM,UAAU,QAAQ,CAAC,IAAa;IACpC,OAAO,CACL,IAAI,KAAK,IAAI,IAAI,OAAO,IAAI,KAAK,QAAQ,IAAI,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,KAAK,KAAK,CAC3E,CAAC;AACJ,CAAC;AAED,MAAM,UAAU,QAAQ,CAAC,IAAa;IACpC,OAAO,OAAO,IAAI,KAAK,QAAQ,CAAC;AAClC,CAAC;AAED,MAAM,UAAU,OAAO,CAAC,IAAa;IACnC,OAAO,IAAI,YAAY,KAAK,CAAC;AAC/B,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,10 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nr1e/commons",
|
|
3
3
|
"description": "Provides common patterns for validation",
|
|
4
|
-
"version": "0.0.3-alpha.
|
|
4
|
+
"version": "0.0.3-alpha.16",
|
|
5
5
|
"type": "module",
|
|
6
|
-
"module": "dist/index.js",
|
|
7
|
-
"types": "dist/index.d.ts",
|
|
8
6
|
"author": "NR1E, Inc.",
|
|
9
7
|
"publishConfig": {
|
|
10
8
|
"access": "public"
|
|
@@ -19,8 +17,7 @@
|
|
|
19
17
|
},
|
|
20
18
|
"homepage": "https://github.com/nr1etech/commons-js#readme",
|
|
21
19
|
"files": [
|
|
22
|
-
"
|
|
23
|
-
"!dist/**/*.test.*"
|
|
20
|
+
"**"
|
|
24
21
|
],
|
|
25
22
|
"devDependencies": {
|
|
26
23
|
"@types/node": "20.8.2",
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './validators';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/validator/index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAC"}
|
|
@@ -0,0 +1,188 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Tests if a value is null or undefined.
|
|
3
|
+
*
|
|
4
|
+
* @param o the value to check
|
|
5
|
+
*/
|
|
6
|
+
export declare function isNotNull(o?: unknown): o is NonNullable<unknown>;
|
|
7
|
+
/**
|
|
8
|
+
* Throws a ValidationError if the value is null or undefined.
|
|
9
|
+
* This function also asserts the value to be NonNullable if the check passes.
|
|
10
|
+
*
|
|
11
|
+
* @param name the name of the variable
|
|
12
|
+
* @param o the value to check
|
|
13
|
+
*/
|
|
14
|
+
export declare function notNull(name: string, o?: unknown): asserts o is NonNullable<unknown>;
|
|
15
|
+
/**
|
|
16
|
+
* Tests if a value is empty, null, undefined or has a length of 0.
|
|
17
|
+
*
|
|
18
|
+
* @param o the value to check
|
|
19
|
+
*/
|
|
20
|
+
export declare function isNotEmpty(o?: unknown): o is NonNullable<unknown>;
|
|
21
|
+
/**
|
|
22
|
+
* Throws a ValidationError if the value is null, undefined or the length is 0.
|
|
23
|
+
* This function also asserts the value to be NonNullable if the check passes.
|
|
24
|
+
*
|
|
25
|
+
* @param name the name of the variable
|
|
26
|
+
* @param o the value to check
|
|
27
|
+
*/
|
|
28
|
+
export declare function notEmpty(name: string, o?: unknown): asserts o is NonNullable<unknown>;
|
|
29
|
+
/**
|
|
30
|
+
* Tests if a value is null, undefined, has a length of 0 or contains only whitespace.
|
|
31
|
+
*
|
|
32
|
+
* @param o the value to check
|
|
33
|
+
*/
|
|
34
|
+
export declare function isNotBlank(o?: unknown): o is NonNullable<unknown>;
|
|
35
|
+
/**
|
|
36
|
+
* Throws a ValidationError if the value is null, undefined, has a length of 0 or contains only whitespace.
|
|
37
|
+
* This function also asserts the value to be NonNullable if the check passes.
|
|
38
|
+
*
|
|
39
|
+
* @param name the name of the variable
|
|
40
|
+
* @param o the value to check
|
|
41
|
+
*/
|
|
42
|
+
export declare function notBlank(name: string, o?: unknown): asserts o is NonNullable<unknown>;
|
|
43
|
+
/**
|
|
44
|
+
* Tests if a value does not match the regular expression provided.
|
|
45
|
+
* Undefined and null values are skipped and not tested.
|
|
46
|
+
*
|
|
47
|
+
* @param regex the regular expression to test with
|
|
48
|
+
* @param o the value to check
|
|
49
|
+
*/
|
|
50
|
+
export declare function isMatch(regex: RegExp, o?: string | null): o is string;
|
|
51
|
+
/**
|
|
52
|
+
* Throws a ValidationError if the value matches the regular expression provided.
|
|
53
|
+
* Undefined and null values are skipped and not validated.
|
|
54
|
+
*
|
|
55
|
+
* @param name the name of the variable
|
|
56
|
+
* @param regex the regular expression to validate with
|
|
57
|
+
* @param o the value to check
|
|
58
|
+
*/
|
|
59
|
+
export declare function match(name: string, regex: RegExp, o?: string | null): void;
|
|
60
|
+
/**
|
|
61
|
+
* Tests if a value is a valid email address.
|
|
62
|
+
* Undefined and null values are skipped and not validated.
|
|
63
|
+
*
|
|
64
|
+
* @param o the value to check
|
|
65
|
+
*/
|
|
66
|
+
export declare function isEmail(o?: string | null): o is string;
|
|
67
|
+
/**
|
|
68
|
+
* Throws a ValidationError if the value provided is not an email.
|
|
69
|
+
* Undefined and null values are skipped and not validated.
|
|
70
|
+
*
|
|
71
|
+
* @param name the name of the variable
|
|
72
|
+
* @param o the value to check
|
|
73
|
+
*/
|
|
74
|
+
export declare function email(name: string, o?: string | null): void;
|
|
75
|
+
/**
|
|
76
|
+
* Tests if a value has a length that is less than the provided length.
|
|
77
|
+
* Undefined and null values are skipped and not validated.
|
|
78
|
+
*
|
|
79
|
+
* @param length the maximum length of the variable
|
|
80
|
+
* @param o the value to check
|
|
81
|
+
*/
|
|
82
|
+
export declare function isMaxLength(length: number, o?: string | unknown[] | null): boolean;
|
|
83
|
+
/**
|
|
84
|
+
* Throws a ValidationError if the value provided has a length that exceeds the provided length.
|
|
85
|
+
* Undefined and null values are skipped and not validated.
|
|
86
|
+
*
|
|
87
|
+
* @param name the name of the variable
|
|
88
|
+
* @param length the maximum length of the variable
|
|
89
|
+
* @param o the value to check
|
|
90
|
+
*/
|
|
91
|
+
export declare function maxLength(name: string, length: number, o?: string | unknown[] | null): void;
|
|
92
|
+
/**
|
|
93
|
+
* Tests if a value has a length that is greater than the provided length.
|
|
94
|
+
* Undefined and null values are skipped and not validated.
|
|
95
|
+
*
|
|
96
|
+
* @param length the minimum length of the variable
|
|
97
|
+
* @param o the value to check
|
|
98
|
+
*/
|
|
99
|
+
export declare function isMinLength(length: number, o?: string | unknown[] | null): boolean;
|
|
100
|
+
/**
|
|
101
|
+
* Throws a ValidationError if the value provided has a length that is less than the provided length.
|
|
102
|
+
* Undefined and null values are skipped and not validated.
|
|
103
|
+
*
|
|
104
|
+
* @param name the name of the variable
|
|
105
|
+
* @param length the minimum length of the variable
|
|
106
|
+
* @param o the value to check
|
|
107
|
+
*/
|
|
108
|
+
export declare function minLength(name: string, length: number, o?: string | unknown[] | null): void;
|
|
109
|
+
/**
|
|
110
|
+
* Tests if a value provided is a number.
|
|
111
|
+
* Undefined and null values are skipped and not validated.
|
|
112
|
+
*
|
|
113
|
+
* @param o the value to check
|
|
114
|
+
*/
|
|
115
|
+
export declare function isNumber(o?: string | null | number): boolean;
|
|
116
|
+
/**
|
|
117
|
+
* Throws a ValidationError if the value provided is not a number.
|
|
118
|
+
* Undefined and null values are skipped and not validated.
|
|
119
|
+
*
|
|
120
|
+
* @param name the name of the variable
|
|
121
|
+
* @param o the value to check
|
|
122
|
+
*/
|
|
123
|
+
export declare function number(name: string, o?: string | null | number): void;
|
|
124
|
+
/**
|
|
125
|
+
* Tests if a value is less than the provided minimum value.
|
|
126
|
+
* Undefined and null values are skipped and not validated.
|
|
127
|
+
*
|
|
128
|
+
* @param minValue the minimum value allowed
|
|
129
|
+
* @param o the value to check
|
|
130
|
+
*/
|
|
131
|
+
export declare function isMinValue(minValue: number, o?: string | number | null): boolean;
|
|
132
|
+
/**
|
|
133
|
+
* Throws a ValidationError if the value is less than the provided minimum value.
|
|
134
|
+
* Undefined and null values are skipped and not validated.
|
|
135
|
+
*
|
|
136
|
+
* @param name the name of the variable
|
|
137
|
+
* @param minValue the minimum value allowed
|
|
138
|
+
* @param o the value to check
|
|
139
|
+
*/
|
|
140
|
+
export declare function minValue(name: string, minValue: number, o?: number | string | null): void;
|
|
141
|
+
/**
|
|
142
|
+
* Tests if a value is more than the provided maximum value.
|
|
143
|
+
* Undefined and null values are skipped and not validated.
|
|
144
|
+
*
|
|
145
|
+
* @param maxValue the maximum value allowed
|
|
146
|
+
* @param o the value to check
|
|
147
|
+
*/
|
|
148
|
+
export declare function isMaxValue(maxValue: number, o?: string | number | null): boolean;
|
|
149
|
+
/**
|
|
150
|
+
* Throws a ValidationError if the value is more than the provided maximum value.
|
|
151
|
+
* Undefined and null values are skipped and not validated.
|
|
152
|
+
*
|
|
153
|
+
* @param name the name of the variable
|
|
154
|
+
* @param maxValue the maximum value allowed
|
|
155
|
+
* @param o the value to check
|
|
156
|
+
*/
|
|
157
|
+
export declare function maxValue(name: string, maxValue: number, o?: number | string | null): void;
|
|
158
|
+
/**
|
|
159
|
+
* Tests if the value is between the provided minimum and maximum values inclusive.
|
|
160
|
+
* Undefined and null values are skipped and not validated.
|
|
161
|
+
*
|
|
162
|
+
* @param minValue the minimum value allowed
|
|
163
|
+
* @param maxValue the maximum value allowed
|
|
164
|
+
* @param o the value to check
|
|
165
|
+
*/
|
|
166
|
+
export declare function isBetweenValues(minValue: number, maxValue: number, o?: string | number | null): boolean;
|
|
167
|
+
/**
|
|
168
|
+
* Throws a ValidationError if the value is not between the provided minimum and maximum values inclusive.
|
|
169
|
+
* Undefined and null values are skipped and not validated.
|
|
170
|
+
*
|
|
171
|
+
* @param name the name of the variable
|
|
172
|
+
* @param minValue the minimum value allowed
|
|
173
|
+
* @param maxValue the maximum value allowed
|
|
174
|
+
* @param o the value to check
|
|
175
|
+
*/
|
|
176
|
+
export declare function betweenValues(name: string, minValue: number, maxValue: number, o?: string | number | null): void;
|
|
177
|
+
export interface StringValidationOptions {
|
|
178
|
+
readonly required: boolean;
|
|
179
|
+
readonly minLength?: number;
|
|
180
|
+
readonly maxLength?: number;
|
|
181
|
+
readonly regex?: RegExp;
|
|
182
|
+
readonly notBlank?: boolean;
|
|
183
|
+
readonly notEmpty?: boolean;
|
|
184
|
+
readonly email?: boolean;
|
|
185
|
+
readonly number?: boolean;
|
|
186
|
+
}
|
|
187
|
+
export declare function isValidString(options: StringValidationOptions, value?: unknown): value is string;
|
|
188
|
+
export declare function validString(name: string, options: StringValidationOptions, value?: unknown): void;
|
|
@@ -0,0 +1,302 @@
|
|
|
1
|
+
import { ValidationError } from '../errors';
|
|
2
|
+
/**
|
|
3
|
+
* Tests if a value is null or undefined.
|
|
4
|
+
*
|
|
5
|
+
* @param o the value to check
|
|
6
|
+
*/
|
|
7
|
+
export function isNotNull(o) {
|
|
8
|
+
return o !== undefined && o !== null;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Throws a ValidationError if the value is null or undefined.
|
|
12
|
+
* This function also asserts the value to be NonNullable if the check passes.
|
|
13
|
+
*
|
|
14
|
+
* @param name the name of the variable
|
|
15
|
+
* @param o the value to check
|
|
16
|
+
*/
|
|
17
|
+
export function notNull(name, o) {
|
|
18
|
+
if (!isNotNull(o)) {
|
|
19
|
+
throw new ValidationError(`${name} may not be null or undefined`);
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Tests if a value is empty, null, undefined or has a length of 0.
|
|
24
|
+
*
|
|
25
|
+
* @param o the value to check
|
|
26
|
+
*/
|
|
27
|
+
export function isNotEmpty(o) {
|
|
28
|
+
return !(o === undefined || o === null || o.toString().length === 0);
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Throws a ValidationError if the value is null, undefined or the length is 0.
|
|
32
|
+
* This function also asserts the value to be NonNullable if the check passes.
|
|
33
|
+
*
|
|
34
|
+
* @param name the name of the variable
|
|
35
|
+
* @param o the value to check
|
|
36
|
+
*/
|
|
37
|
+
export function notEmpty(name, o) {
|
|
38
|
+
if (!isNotEmpty(o)) {
|
|
39
|
+
throw new ValidationError(`${name} may not be empty`);
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Tests if a value is null, undefined, has a length of 0 or contains only whitespace.
|
|
44
|
+
*
|
|
45
|
+
* @param o the value to check
|
|
46
|
+
*/
|
|
47
|
+
export function isNotBlank(o) {
|
|
48
|
+
return !(o === undefined || o === null || o.toString().trim().length === 0);
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Throws a ValidationError if the value is null, undefined, has a length of 0 or contains only whitespace.
|
|
52
|
+
* This function also asserts the value to be NonNullable if the check passes.
|
|
53
|
+
*
|
|
54
|
+
* @param name the name of the variable
|
|
55
|
+
* @param o the value to check
|
|
56
|
+
*/
|
|
57
|
+
export function notBlank(name, o) {
|
|
58
|
+
if (!isNotBlank(o)) {
|
|
59
|
+
throw new ValidationError(`${name} may not be blank`);
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* Tests if a value does not match the regular expression provided.
|
|
64
|
+
* Undefined and null values are skipped and not tested.
|
|
65
|
+
*
|
|
66
|
+
* @param regex the regular expression to test with
|
|
67
|
+
* @param o the value to check
|
|
68
|
+
*/
|
|
69
|
+
export function isMatch(regex, o) {
|
|
70
|
+
if (o === undefined || o === null) {
|
|
71
|
+
return true;
|
|
72
|
+
}
|
|
73
|
+
return o.match(regex) !== null;
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* Throws a ValidationError if the value matches the regular expression provided.
|
|
77
|
+
* Undefined and null values are skipped and not validated.
|
|
78
|
+
*
|
|
79
|
+
* @param name the name of the variable
|
|
80
|
+
* @param regex the regular expression to validate with
|
|
81
|
+
* @param o the value to check
|
|
82
|
+
*/
|
|
83
|
+
export function match(name, regex, o) {
|
|
84
|
+
if (!isMatch(regex, o)) {
|
|
85
|
+
throw new ValidationError(`${name} must match ${regex}`);
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
/**
|
|
89
|
+
* Tests if a value is a valid email address.
|
|
90
|
+
* Undefined and null values are skipped and not validated.
|
|
91
|
+
*
|
|
92
|
+
* @param o the value to check
|
|
93
|
+
*/
|
|
94
|
+
export function isEmail(o) {
|
|
95
|
+
const expression = /^(?=.{1,254}$)(?=.{1,64}@)[-!#$%&'*+/0-9=?A-Z^_`a-z{|}~]+(\.[-!#$%&'*+/0-9=?A-Z^_`a-z{|}~]+)*@[A-Za-z0-9]([A-Za-z0-9-]{0,61}[A-Za-z0-9])?(\.[A-Za-z0-9]([A-Za-z0-9-]{0,61}[A-Za-z0-9])?)*$/;
|
|
96
|
+
return !(o !== undefined && o !== null && !expression.test(o));
|
|
97
|
+
}
|
|
98
|
+
/**
|
|
99
|
+
* Throws a ValidationError if the value provided is not an email.
|
|
100
|
+
* Undefined and null values are skipped and not validated.
|
|
101
|
+
*
|
|
102
|
+
* @param name the name of the variable
|
|
103
|
+
* @param o the value to check
|
|
104
|
+
*/
|
|
105
|
+
export function email(name, o) {
|
|
106
|
+
if (!isEmail(o)) {
|
|
107
|
+
throw new ValidationError(`${name} is not a valid email address`);
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
/**
|
|
111
|
+
* Tests if a value has a length that is less than the provided length.
|
|
112
|
+
* Undefined and null values are skipped and not validated.
|
|
113
|
+
*
|
|
114
|
+
* @param length the maximum length of the variable
|
|
115
|
+
* @param o the value to check
|
|
116
|
+
*/
|
|
117
|
+
export function isMaxLength(length, o) {
|
|
118
|
+
return !(o !== undefined && o !== null && o.length > length);
|
|
119
|
+
}
|
|
120
|
+
/**
|
|
121
|
+
* Throws a ValidationError if the value provided has a length that exceeds the provided length.
|
|
122
|
+
* Undefined and null values are skipped and not validated.
|
|
123
|
+
*
|
|
124
|
+
* @param name the name of the variable
|
|
125
|
+
* @param length the maximum length of the variable
|
|
126
|
+
* @param o the value to check
|
|
127
|
+
*/
|
|
128
|
+
export function maxLength(name, length, o) {
|
|
129
|
+
if (!isMaxLength(length, o)) {
|
|
130
|
+
throw new ValidationError(`length of ${name} may not exceed ${length}`);
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
/**
|
|
134
|
+
* Tests if a value has a length that is greater than the provided length.
|
|
135
|
+
* Undefined and null values are skipped and not validated.
|
|
136
|
+
*
|
|
137
|
+
* @param length the minimum length of the variable
|
|
138
|
+
* @param o the value to check
|
|
139
|
+
*/
|
|
140
|
+
export function isMinLength(length, o) {
|
|
141
|
+
return !(o !== undefined && o !== null && o.length < length);
|
|
142
|
+
}
|
|
143
|
+
/**
|
|
144
|
+
* Throws a ValidationError if the value provided has a length that is less than the provided length.
|
|
145
|
+
* Undefined and null values are skipped and not validated.
|
|
146
|
+
*
|
|
147
|
+
* @param name the name of the variable
|
|
148
|
+
* @param length the minimum length of the variable
|
|
149
|
+
* @param o the value to check
|
|
150
|
+
*/
|
|
151
|
+
export function minLength(name, length, o) {
|
|
152
|
+
if (!isMinLength(length, o)) {
|
|
153
|
+
throw new ValidationError(`length of ${name} may not be less than ${length}`);
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
/**
|
|
157
|
+
* Tests if a value provided is a number.
|
|
158
|
+
* Undefined and null values are skipped and not validated.
|
|
159
|
+
*
|
|
160
|
+
* @param o the value to check
|
|
161
|
+
*/
|
|
162
|
+
export function isNumber(o) {
|
|
163
|
+
return o === undefined || o === null || !isNaN(+o);
|
|
164
|
+
}
|
|
165
|
+
/**
|
|
166
|
+
* Throws a ValidationError if the value provided is not a number.
|
|
167
|
+
* Undefined and null values are skipped and not validated.
|
|
168
|
+
*
|
|
169
|
+
* @param name the name of the variable
|
|
170
|
+
* @param o the value to check
|
|
171
|
+
*/
|
|
172
|
+
export function number(name, o) {
|
|
173
|
+
if (!isNumber(o)) {
|
|
174
|
+
throw new ValidationError(`${name} is not a number`);
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
/**
|
|
178
|
+
* Tests if a value is less than the provided minimum value.
|
|
179
|
+
* Undefined and null values are skipped and not validated.
|
|
180
|
+
*
|
|
181
|
+
* @param minValue the minimum value allowed
|
|
182
|
+
* @param o the value to check
|
|
183
|
+
*/
|
|
184
|
+
export function isMinValue(minValue, o) {
|
|
185
|
+
return o === undefined || o === null || +o >= minValue;
|
|
186
|
+
}
|
|
187
|
+
/**
|
|
188
|
+
* Throws a ValidationError if the value is less than the provided minimum value.
|
|
189
|
+
* Undefined and null values are skipped and not validated.
|
|
190
|
+
*
|
|
191
|
+
* @param name the name of the variable
|
|
192
|
+
* @param minValue the minimum value allowed
|
|
193
|
+
* @param o the value to check
|
|
194
|
+
*/
|
|
195
|
+
export function minValue(name, minValue, o) {
|
|
196
|
+
if (!isMinValue(minValue, o)) {
|
|
197
|
+
throw new ValidationError(`${name} may not be less than ${minValue}`);
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
/**
|
|
201
|
+
* Tests if a value is more than the provided maximum value.
|
|
202
|
+
* Undefined and null values are skipped and not validated.
|
|
203
|
+
*
|
|
204
|
+
* @param maxValue the maximum value allowed
|
|
205
|
+
* @param o the value to check
|
|
206
|
+
*/
|
|
207
|
+
export function isMaxValue(maxValue, o) {
|
|
208
|
+
return !(o !== undefined && o !== null && +o > maxValue);
|
|
209
|
+
}
|
|
210
|
+
/**
|
|
211
|
+
* Throws a ValidationError if the value is more than the provided maximum value.
|
|
212
|
+
* Undefined and null values are skipped and not validated.
|
|
213
|
+
*
|
|
214
|
+
* @param name the name of the variable
|
|
215
|
+
* @param maxValue the maximum value allowed
|
|
216
|
+
* @param o the value to check
|
|
217
|
+
*/
|
|
218
|
+
export function maxValue(name, maxValue, o) {
|
|
219
|
+
if (!isMaxValue(maxValue, o)) {
|
|
220
|
+
throw new ValidationError(`${name} may not be greater than ${maxValue}`);
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
/**
|
|
224
|
+
* Tests if the value is between the provided minimum and maximum values inclusive.
|
|
225
|
+
* Undefined and null values are skipped and not validated.
|
|
226
|
+
*
|
|
227
|
+
* @param minValue the minimum value allowed
|
|
228
|
+
* @param maxValue the maximum value allowed
|
|
229
|
+
* @param o the value to check
|
|
230
|
+
*/
|
|
231
|
+
export function isBetweenValues(minValue, maxValue, o) {
|
|
232
|
+
return !(o !== undefined && o !== null && (+o < minValue || +o > maxValue));
|
|
233
|
+
}
|
|
234
|
+
/**
|
|
235
|
+
* Throws a ValidationError if the value is not between the provided minimum and maximum values inclusive.
|
|
236
|
+
* Undefined and null values are skipped and not validated.
|
|
237
|
+
*
|
|
238
|
+
* @param name the name of the variable
|
|
239
|
+
* @param minValue the minimum value allowed
|
|
240
|
+
* @param maxValue the maximum value allowed
|
|
241
|
+
* @param o the value to check
|
|
242
|
+
*/
|
|
243
|
+
export function betweenValues(name, minValue, maxValue, o) {
|
|
244
|
+
if (!isBetweenValues(minValue, maxValue, o)) {
|
|
245
|
+
throw new ValidationError(`${name} must be between ${minValue} and ${maxValue}`);
|
|
246
|
+
}
|
|
247
|
+
}
|
|
248
|
+
const isString = (value) => typeof value === 'string';
|
|
249
|
+
export function isValidString(options, value) {
|
|
250
|
+
if (options.required) {
|
|
251
|
+
if (!isNotNull(value)) {
|
|
252
|
+
return false;
|
|
253
|
+
}
|
|
254
|
+
}
|
|
255
|
+
else if (value === undefined || value === null) {
|
|
256
|
+
return true;
|
|
257
|
+
}
|
|
258
|
+
if (!isString(value)) {
|
|
259
|
+
return false;
|
|
260
|
+
}
|
|
261
|
+
if (options.minLength && !isMinLength(options.minLength, value)) {
|
|
262
|
+
return false;
|
|
263
|
+
}
|
|
264
|
+
if (options.maxLength && !isMaxLength(options.maxLength, value)) {
|
|
265
|
+
return false;
|
|
266
|
+
}
|
|
267
|
+
if (options.regex && !isMatch(options.regex, value)) {
|
|
268
|
+
return false;
|
|
269
|
+
}
|
|
270
|
+
if (options.notBlank && !isNotBlank(value)) {
|
|
271
|
+
return false;
|
|
272
|
+
}
|
|
273
|
+
if (options.notEmpty && !isNotEmpty(value)) {
|
|
274
|
+
return false;
|
|
275
|
+
}
|
|
276
|
+
if (options.email && !isEmail(value)) {
|
|
277
|
+
return false;
|
|
278
|
+
}
|
|
279
|
+
if (options.number && !isNumber(value)) {
|
|
280
|
+
return false;
|
|
281
|
+
}
|
|
282
|
+
return true;
|
|
283
|
+
}
|
|
284
|
+
export function validString(name, options, value) {
|
|
285
|
+
if (options.required) {
|
|
286
|
+
notNull(name, value);
|
|
287
|
+
}
|
|
288
|
+
else if (value === undefined || value === null) {
|
|
289
|
+
return;
|
|
290
|
+
}
|
|
291
|
+
if (!isString(value)) {
|
|
292
|
+
throw new ValidationError(`${name} must be a string`);
|
|
293
|
+
}
|
|
294
|
+
options.minLength && minLength(name, options.minLength, value);
|
|
295
|
+
options.maxLength && maxLength(name, options.maxLength, value);
|
|
296
|
+
options.regex && match(name, options.regex, value);
|
|
297
|
+
options.notBlank && notBlank(name, value);
|
|
298
|
+
options.notEmpty && notEmpty(name, value);
|
|
299
|
+
options.email && email(name, value);
|
|
300
|
+
options.number && number(name, value);
|
|
301
|
+
}
|
|
302
|
+
//# sourceMappingURL=validators.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"validators.js","sourceRoot":"","sources":["../../src/validator/validators.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,eAAe,EAAC,MAAM,WAAW,CAAC;AAE1C;;;;GAIG;AACH,MAAM,UAAU,SAAS,CAAC,CAAW;IACnC,OAAO,CAAC,KAAK,SAAS,IAAI,CAAC,KAAK,IAAI,CAAC;AACvC,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,OAAO,CACrB,IAAY,EACZ,CAAW;IAEX,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,EAAE;QACjB,MAAM,IAAI,eAAe,CAAC,GAAG,IAAI,+BAA+B,CAAC,CAAC;KACnE;AACH,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,UAAU,CAAC,CAAW;IACpC,OAAO,CAAC,CAAC,CAAC,KAAK,SAAS,IAAI,CAAC,KAAK,IAAI,IAAI,CAAC,CAAC,QAAQ,EAAE,CAAC,MAAM,KAAK,CAAC,CAAC,CAAC;AACvE,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,QAAQ,CACtB,IAAY,EACZ,CAAW;IAEX,IAAI,CAAC,UAAU,CA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