valgen 5.13.2 → 5.13.3
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/CHANGELOG.md
CHANGED
|
@@ -12,39 +12,41 @@ function isEmpty(options) {
|
|
|
12
12
|
if (input == null)
|
|
13
13
|
return input;
|
|
14
14
|
if (typeof input === 'string') {
|
|
15
|
-
if (
|
|
16
|
-
|
|
17
|
-
|
|
15
|
+
if (input)
|
|
16
|
+
context.fail(_this, `Value must be an empty string`, input);
|
|
17
|
+
return input;
|
|
18
18
|
}
|
|
19
19
|
else if (Array.isArray(input)) {
|
|
20
|
-
if (
|
|
21
|
-
|
|
22
|
-
|
|
20
|
+
if (input.length)
|
|
21
|
+
context.fail(_this, `Value must be an empty array`, input);
|
|
22
|
+
return input;
|
|
23
23
|
}
|
|
24
24
|
else if (input instanceof Set) {
|
|
25
|
-
if (
|
|
26
|
-
|
|
27
|
-
|
|
25
|
+
if (input.size)
|
|
26
|
+
context.fail(_this, `Value must be an empty Set`, input);
|
|
27
|
+
return input;
|
|
28
28
|
}
|
|
29
29
|
else if (input instanceof Map) {
|
|
30
|
-
if (
|
|
31
|
-
|
|
32
|
-
|
|
30
|
+
if (input.size)
|
|
31
|
+
context.fail(_this, `Value must be an empty Map`, input);
|
|
32
|
+
return input;
|
|
33
33
|
}
|
|
34
34
|
else if (Buffer.isBuffer(input)) {
|
|
35
|
-
if (
|
|
36
|
-
|
|
37
|
-
|
|
35
|
+
if (input.length)
|
|
36
|
+
context.fail(_this, `Value must be an empty Buffer`, input);
|
|
37
|
+
return input;
|
|
38
38
|
}
|
|
39
39
|
else if (input instanceof ArrayBuffer) {
|
|
40
|
-
if (
|
|
41
|
-
|
|
42
|
-
|
|
40
|
+
if (input.byteLength)
|
|
41
|
+
context.fail(_this, `Value must be an empty ArrayBuffer`, input);
|
|
42
|
+
return input;
|
|
43
43
|
}
|
|
44
44
|
else if (typeof input === 'object') {
|
|
45
|
-
if (input instanceof Date
|
|
45
|
+
if (input instanceof Date)
|
|
46
46
|
return input;
|
|
47
|
-
|
|
47
|
+
if (Object.keys(input).length)
|
|
48
|
+
context.fail(_this, `Value must be an empty Object`, input);
|
|
49
|
+
return input;
|
|
48
50
|
}
|
|
49
51
|
context.fail(_this, `Value must be empty`, input);
|
|
50
52
|
}, options);
|
|
@@ -57,41 +59,44 @@ function isNotEmpty(options) {
|
|
|
57
59
|
return (0, index_js_1.validator)('isNotEmpty', (input, context, _this) => {
|
|
58
60
|
if (input != null) {
|
|
59
61
|
if (typeof input === 'string') {
|
|
60
|
-
if (input)
|
|
61
|
-
|
|
62
|
-
|
|
62
|
+
if (!input)
|
|
63
|
+
context.fail(_this, `Value must not be empty`, input);
|
|
64
|
+
return input;
|
|
63
65
|
}
|
|
64
66
|
else if (Array.isArray(input)) {
|
|
65
|
-
if (input.length)
|
|
66
|
-
|
|
67
|
-
|
|
67
|
+
if (!input.length)
|
|
68
|
+
context.fail(_this, `Array must not be empty`, input);
|
|
69
|
+
return input;
|
|
68
70
|
}
|
|
69
71
|
else if (input instanceof Set) {
|
|
70
|
-
if (input.size)
|
|
71
|
-
|
|
72
|
-
|
|
72
|
+
if (!input.size)
|
|
73
|
+
context.fail(_this, `Set must not be empty`, input);
|
|
74
|
+
return input;
|
|
73
75
|
}
|
|
74
76
|
else if (input instanceof Map) {
|
|
75
|
-
if (input.size)
|
|
76
|
-
|
|
77
|
-
|
|
77
|
+
if (!input.size)
|
|
78
|
+
context.fail(_this, `Map must not be empty`, input);
|
|
79
|
+
return input;
|
|
78
80
|
}
|
|
79
81
|
else if (Buffer.isBuffer(input)) {
|
|
80
|
-
if (input.length)
|
|
81
|
-
|
|
82
|
-
|
|
82
|
+
if (!input.length)
|
|
83
|
+
context.fail(_this, `Buffer must not be empty`, input);
|
|
84
|
+
return input;
|
|
83
85
|
}
|
|
84
86
|
else if (input instanceof ArrayBuffer) {
|
|
85
|
-
if (input.byteLength)
|
|
86
|
-
|
|
87
|
-
|
|
87
|
+
if (!input.byteLength)
|
|
88
|
+
context.fail(_this, `ArrayBuffer must not be empty`, input);
|
|
89
|
+
return input;
|
|
88
90
|
}
|
|
89
91
|
else if (typeof input === 'object') {
|
|
90
|
-
if (input instanceof Date
|
|
92
|
+
if (input instanceof Date)
|
|
91
93
|
return input;
|
|
92
|
-
|
|
94
|
+
if (!Object.keys(input).length)
|
|
95
|
+
context.fail(_this, `Object must not be empty`, input);
|
|
96
|
+
return input;
|
|
93
97
|
}
|
|
94
98
|
}
|
|
95
99
|
context.fail(_this, `Value must not be empty`, input);
|
|
100
|
+
return input;
|
|
96
101
|
}, options);
|
|
97
102
|
}
|
|
@@ -8,39 +8,41 @@ export function isEmpty(options) {
|
|
|
8
8
|
if (input == null)
|
|
9
9
|
return input;
|
|
10
10
|
if (typeof input === 'string') {
|
|
11
|
-
if (
|
|
12
|
-
|
|
13
|
-
|
|
11
|
+
if (input)
|
|
12
|
+
context.fail(_this, `Value must be an empty string`, input);
|
|
13
|
+
return input;
|
|
14
14
|
}
|
|
15
15
|
else if (Array.isArray(input)) {
|
|
16
|
-
if (
|
|
17
|
-
|
|
18
|
-
|
|
16
|
+
if (input.length)
|
|
17
|
+
context.fail(_this, `Value must be an empty array`, input);
|
|
18
|
+
return input;
|
|
19
19
|
}
|
|
20
20
|
else if (input instanceof Set) {
|
|
21
|
-
if (
|
|
22
|
-
|
|
23
|
-
|
|
21
|
+
if (input.size)
|
|
22
|
+
context.fail(_this, `Value must be an empty Set`, input);
|
|
23
|
+
return input;
|
|
24
24
|
}
|
|
25
25
|
else if (input instanceof Map) {
|
|
26
|
-
if (
|
|
27
|
-
|
|
28
|
-
|
|
26
|
+
if (input.size)
|
|
27
|
+
context.fail(_this, `Value must be an empty Map`, input);
|
|
28
|
+
return input;
|
|
29
29
|
}
|
|
30
30
|
else if (Buffer.isBuffer(input)) {
|
|
31
|
-
if (
|
|
32
|
-
|
|
33
|
-
|
|
31
|
+
if (input.length)
|
|
32
|
+
context.fail(_this, `Value must be an empty Buffer`, input);
|
|
33
|
+
return input;
|
|
34
34
|
}
|
|
35
35
|
else if (input instanceof ArrayBuffer) {
|
|
36
|
-
if (
|
|
37
|
-
|
|
38
|
-
|
|
36
|
+
if (input.byteLength)
|
|
37
|
+
context.fail(_this, `Value must be an empty ArrayBuffer`, input);
|
|
38
|
+
return input;
|
|
39
39
|
}
|
|
40
40
|
else if (typeof input === 'object') {
|
|
41
|
-
if (input instanceof Date
|
|
41
|
+
if (input instanceof Date)
|
|
42
42
|
return input;
|
|
43
|
-
|
|
43
|
+
if (Object.keys(input).length)
|
|
44
|
+
context.fail(_this, `Value must be an empty Object`, input);
|
|
45
|
+
return input;
|
|
44
46
|
}
|
|
45
47
|
context.fail(_this, `Value must be empty`, input);
|
|
46
48
|
}, options);
|
|
@@ -53,41 +55,44 @@ export function isNotEmpty(options) {
|
|
|
53
55
|
return validator('isNotEmpty', (input, context, _this) => {
|
|
54
56
|
if (input != null) {
|
|
55
57
|
if (typeof input === 'string') {
|
|
56
|
-
if (input)
|
|
57
|
-
|
|
58
|
-
|
|
58
|
+
if (!input)
|
|
59
|
+
context.fail(_this, `Value must not be empty`, input);
|
|
60
|
+
return input;
|
|
59
61
|
}
|
|
60
62
|
else if (Array.isArray(input)) {
|
|
61
|
-
if (input.length)
|
|
62
|
-
|
|
63
|
-
|
|
63
|
+
if (!input.length)
|
|
64
|
+
context.fail(_this, `Array must not be empty`, input);
|
|
65
|
+
return input;
|
|
64
66
|
}
|
|
65
67
|
else if (input instanceof Set) {
|
|
66
|
-
if (input.size)
|
|
67
|
-
|
|
68
|
-
|
|
68
|
+
if (!input.size)
|
|
69
|
+
context.fail(_this, `Set must not be empty`, input);
|
|
70
|
+
return input;
|
|
69
71
|
}
|
|
70
72
|
else if (input instanceof Map) {
|
|
71
|
-
if (input.size)
|
|
72
|
-
|
|
73
|
-
|
|
73
|
+
if (!input.size)
|
|
74
|
+
context.fail(_this, `Map must not be empty`, input);
|
|
75
|
+
return input;
|
|
74
76
|
}
|
|
75
77
|
else if (Buffer.isBuffer(input)) {
|
|
76
|
-
if (input.length)
|
|
77
|
-
|
|
78
|
-
|
|
78
|
+
if (!input.length)
|
|
79
|
+
context.fail(_this, `Buffer must not be empty`, input);
|
|
80
|
+
return input;
|
|
79
81
|
}
|
|
80
82
|
else if (input instanceof ArrayBuffer) {
|
|
81
|
-
if (input.byteLength)
|
|
82
|
-
|
|
83
|
-
|
|
83
|
+
if (!input.byteLength)
|
|
84
|
+
context.fail(_this, `ArrayBuffer must not be empty`, input);
|
|
85
|
+
return input;
|
|
84
86
|
}
|
|
85
87
|
else if (typeof input === 'object') {
|
|
86
|
-
if (input instanceof Date
|
|
88
|
+
if (input instanceof Date)
|
|
87
89
|
return input;
|
|
88
|
-
|
|
90
|
+
if (!Object.keys(input).length)
|
|
91
|
+
context.fail(_this, `Object must not be empty`, input);
|
|
92
|
+
return input;
|
|
89
93
|
}
|
|
90
94
|
}
|
|
91
95
|
context.fail(_this, `Value must not be empty`, input);
|
|
96
|
+
return input;
|
|
92
97
|
}, options);
|
|
93
98
|
}
|