valgen 4.0.0 → 4.0.1
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 +7 -0
- package/cjs/rules/is-null.js +5 -1
- package/esm/rules/is-null.js +5 -1
- package/package.json +3 -3
- package/typings/rules/is-null.d.ts +1 -1
package/CHANGELOG.md
CHANGED
package/cjs/rules/is-null.js
CHANGED
|
@@ -8,6 +8,8 @@ const index_js_1 = require("../core/index.js");
|
|
|
8
8
|
*/
|
|
9
9
|
function isNull(options) {
|
|
10
10
|
return (0, index_js_1.validator)('isNull', function (input, context, _this) {
|
|
11
|
+
if (context.coerce)
|
|
12
|
+
return null;
|
|
11
13
|
if (input === null)
|
|
12
14
|
return input;
|
|
13
15
|
context.fail(_this, `{{label}} is not null`, input);
|
|
@@ -28,10 +30,12 @@ function isDefined(options) {
|
|
|
28
30
|
exports.isDefined = isDefined;
|
|
29
31
|
/**
|
|
30
32
|
* Validates if value is "undefined"
|
|
31
|
-
* @validator
|
|
33
|
+
* @validator isUndefined
|
|
32
34
|
*/
|
|
33
35
|
function isUndefined(options) {
|
|
34
36
|
return (0, index_js_1.validator)('isUndefined', function (input, context, _this) {
|
|
37
|
+
if (context.coerce)
|
|
38
|
+
return undefined;
|
|
35
39
|
if (input === undefined)
|
|
36
40
|
return;
|
|
37
41
|
context.fail(_this, `{{label}} defined`, input);
|
package/esm/rules/is-null.js
CHANGED
|
@@ -5,6 +5,8 @@ import { validator } from '../core/index.js';
|
|
|
5
5
|
*/
|
|
6
6
|
export function isNull(options) {
|
|
7
7
|
return validator('isNull', function (input, context, _this) {
|
|
8
|
+
if (context.coerce)
|
|
9
|
+
return null;
|
|
8
10
|
if (input === null)
|
|
9
11
|
return input;
|
|
10
12
|
context.fail(_this, `{{label}} is not null`, input);
|
|
@@ -23,10 +25,12 @@ export function isDefined(options) {
|
|
|
23
25
|
}
|
|
24
26
|
/**
|
|
25
27
|
* Validates if value is "undefined"
|
|
26
|
-
* @validator
|
|
28
|
+
* @validator isUndefined
|
|
27
29
|
*/
|
|
28
30
|
export function isUndefined(options) {
|
|
29
31
|
return validator('isUndefined', function (input, context, _this) {
|
|
32
|
+
if (context.coerce)
|
|
33
|
+
return undefined;
|
|
30
34
|
if (input === undefined)
|
|
31
35
|
return;
|
|
32
36
|
context.fail(_this, `{{label}} defined`, input);
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "valgen",
|
|
3
3
|
"description": "Fast runtime type validator, converter and io (encoding/decoding) library",
|
|
4
|
-
"version": "4.0.
|
|
4
|
+
"version": "4.0.1",
|
|
5
5
|
"author": "Panates",
|
|
6
6
|
"contributors": [
|
|
7
7
|
"Eray Hanoglu <e.hanoglu@panates.com>"
|
|
@@ -12,9 +12,9 @@
|
|
|
12
12
|
"url": "https://github.com/panates/valgen.git"
|
|
13
13
|
},
|
|
14
14
|
"dependencies": {
|
|
15
|
-
"@types/validator": "^13.11.
|
|
15
|
+
"@types/validator": "^13.11.5",
|
|
16
16
|
"dayjs": "^2.0.0-alpha.4",
|
|
17
|
-
"ts-gems": "^2.
|
|
17
|
+
"ts-gems": "^2.5.0",
|
|
18
18
|
"validator": "^13.11.0"
|
|
19
19
|
},
|
|
20
20
|
"type": "module",
|
|
@@ -11,6 +11,6 @@ export declare function isNull(options?: ValidationOptions): import("../core/val
|
|
|
11
11
|
export declare function isDefined(options?: ValidationOptions): import("../core/validator.js").Validator<any, unknown, import("../core/types.js").ExecutionOptions>;
|
|
12
12
|
/**
|
|
13
13
|
* Validates if value is "undefined"
|
|
14
|
-
* @validator
|
|
14
|
+
* @validator isUndefined
|
|
15
15
|
*/
|
|
16
16
|
export declare function isUndefined(options?: ValidationOptions): import("../core/validator.js").Validator<any, unknown, import("../core/types.js").ExecutionOptions>;
|