valgen 5.5.0 → 5.6.0
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 +8 -0
- package/cjs/index.js +6 -2
- package/cjs/rules/type-rules/is-null.js +30 -3
- package/esm/index.js +3 -1
- package/esm/rules/type-rules/is-null.js +28 -3
- package/package.json +1 -1
- package/typings/index.d.ts +3 -1
- package/typings/rules/type-rules/is-null.d.ts +11 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,11 @@
|
|
|
1
|
+
# v5.6.0
|
|
2
|
+
[2024-07-14]
|
|
3
|
+
|
|
4
|
+
### Changes
|
|
5
|
+
|
|
6
|
+
* Added isNotNull and isNotNullish rules ([`19902a5`](https://github.com/panates/valgen/commit/19902a5e2a12f1958952671ffce6e2eab77457a5))
|
|
7
|
+
* Added isNotNull and isNotNullish rules ([`ff881d6`](https://github.com/panates/valgen/commit/ff881d6be81068c70e020109485b91854c355598))
|
|
8
|
+
|
|
1
9
|
# v5.5.0
|
|
2
10
|
[2024-07-14]
|
|
3
11
|
|
package/cjs/index.js
CHANGED
|
@@ -26,8 +26,8 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
26
26
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
27
27
|
};
|
|
28
28
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
-
exports.
|
|
30
|
-
exports.vg = exports.toString = exports.toNumber = exports.toInteger = exports.toDateString = exports.toDate = exports.toBoolean = void 0;
|
|
29
|
+
exports.isUUID5 = exports.isUUID4 = exports.isUUID3 = exports.isUUID2 = exports.isUUID1 = exports.isUUID = exports.isURL = exports.isUppercase = exports.isUndefined = exports.isSWIFT = exports.isString = exports.isPort = exports.isObjectId = exports.isObject = exports.isNumber = exports.isNullish = exports.isNull = exports.isNotNullish = exports.isNotNull = exports.isNotEmpty = exports.isMobilePhone = exports.isMACAddress = exports.isLowercase = exports.isJWT = exports.isISSN = exports.isIPRange = exports.isIP = exports.isInteger = exports.isIBAN = exports.isHexColor = exports.isHex = exports.isFQDN = exports.isETHAddress = exports.isEmpty = exports.isEmail = exports.isEAN = exports.isDefined = exports.isDecimal = exports.isDateString = exports.isDate = exports.isCreditCard = exports.isBtcAddress = exports.isBoolean = exports.isBigint = exports.isBase64 = exports.isAscii = exports.isArray = exports.isAny = exports.isAlphanumeric = exports.isAlpha = void 0;
|
|
30
|
+
exports.vg = exports.toString = exports.toNumber = exports.toInteger = exports.toDateString = exports.toDate = exports.toBoolean = exports.toBigint = exports.toArray = void 0;
|
|
31
31
|
const vg = __importStar(require("./rules/index.js"));
|
|
32
32
|
exports.vg = vg;
|
|
33
33
|
__exportStar(require("./constants.js"), exports);
|
|
@@ -52,8 +52,12 @@ const isInteger = vg.isInteger();
|
|
|
52
52
|
exports.isInteger = isInteger;
|
|
53
53
|
const isNull = vg.isNull();
|
|
54
54
|
exports.isNull = isNull;
|
|
55
|
+
const isNotNull = vg.isNotNull();
|
|
56
|
+
exports.isNotNull = isNotNull;
|
|
55
57
|
const isNullish = vg.isNullish();
|
|
56
58
|
exports.isNullish = isNullish;
|
|
59
|
+
const isNotNullish = vg.isNotNullish();
|
|
60
|
+
exports.isNotNullish = isNotNullish;
|
|
57
61
|
const isDefined = vg.isDefined();
|
|
58
62
|
exports.isDefined = isDefined;
|
|
59
63
|
const isUndefined = vg.isUndefined();
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.isNull = isNull;
|
|
4
|
+
exports.isNotNull = isNotNull;
|
|
4
5
|
exports.isNullish = isNullish;
|
|
6
|
+
exports.isNotNullish = isNotNullish;
|
|
5
7
|
const index_js_1 = require("../../core/index.js");
|
|
6
8
|
/**
|
|
7
9
|
* Validates if value is "null".
|
|
@@ -11,17 +13,42 @@ function isNull(options) {
|
|
|
11
13
|
return (0, index_js_1.validator)('isNull', (input, context, _this) => {
|
|
12
14
|
if (input === null)
|
|
13
15
|
return input;
|
|
14
|
-
context.fail(_this, `
|
|
16
|
+
context.fail(_this, `{{label}} is not null`, input);
|
|
17
|
+
}, options);
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Validates if value is not "null".
|
|
21
|
+
* @validator isNotNull
|
|
22
|
+
*/
|
|
23
|
+
function isNotNull(options) {
|
|
24
|
+
return (0, index_js_1.validator)('isNotNull', (input, context, _this) => {
|
|
25
|
+
if (input !== null)
|
|
26
|
+
return input;
|
|
27
|
+
context.fail(_this, `{{label}} is null`, input);
|
|
15
28
|
}, options);
|
|
16
29
|
}
|
|
17
30
|
/**
|
|
18
31
|
* Validates if value is "null" or "undefined".
|
|
19
|
-
* @validator
|
|
32
|
+
* @validator isNullish
|
|
20
33
|
*/
|
|
21
34
|
function isNullish(options) {
|
|
22
35
|
return (0, index_js_1.validator)('isNullish', (input, context, _this) => {
|
|
23
36
|
if (input == null)
|
|
24
37
|
return input;
|
|
25
|
-
context.fail(_this, `
|
|
38
|
+
context.fail(_this, `{{label}} is not nullish`, input);
|
|
39
|
+
}, options);
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Validates if value is not "null" nor "undefined".
|
|
43
|
+
* @validator isNotNullish
|
|
44
|
+
*/
|
|
45
|
+
function isNotNullish(options) {
|
|
46
|
+
return (0, index_js_1.validator)('isNotNullish', (input, context, _this) => {
|
|
47
|
+
if (input != null)
|
|
48
|
+
return input;
|
|
49
|
+
if (input === null)
|
|
50
|
+
context.fail(_this, `{{label}} is null`, input);
|
|
51
|
+
else
|
|
52
|
+
context.fail(_this, `{{label}} is undefined`, input);
|
|
26
53
|
}, options);
|
|
27
54
|
}
|
package/esm/index.js
CHANGED
|
@@ -11,7 +11,9 @@ const isEmpty = vg.isEmpty();
|
|
|
11
11
|
const isNotEmpty = vg.isNotEmpty();
|
|
12
12
|
const isInteger = vg.isInteger();
|
|
13
13
|
const isNull = vg.isNull();
|
|
14
|
+
const isNotNull = vg.isNotNull();
|
|
14
15
|
const isNullish = vg.isNullish();
|
|
16
|
+
const isNotNullish = vg.isNotNullish();
|
|
15
17
|
const isDefined = vg.isDefined();
|
|
16
18
|
const isUndefined = vg.isUndefined();
|
|
17
19
|
const isNumber = vg.isNumber();
|
|
@@ -57,4 +59,4 @@ const toDateString = vg.isDateString({ coerce: true });
|
|
|
57
59
|
const toInteger = vg.isInteger({ coerce: true });
|
|
58
60
|
const toNumber = vg.isNumber({ coerce: true });
|
|
59
61
|
const toString = vg.isString({ coerce: true });
|
|
60
|
-
export { isAlpha, isAlphanumeric, isAny, isArray, isAscii, isBase64, isBigint, isBoolean, isBtcAddress, isCreditCard, isDate, isDateString, isDecimal, isDefined, isEAN, isEmail, isEmpty, isETHAddress, isFQDN, isHex, isHexColor, isIBAN, isInteger, isIP, isIPRange, isISSN, isJWT, isLowercase, isMACAddress, isMobilePhone, isNotEmpty, isNull, isNullish, isNumber, isObject, isObjectId, isPort, isString, isSWIFT, isUndefined, isUppercase, isURL, isUUID, isUUID1, isUUID2, isUUID3, isUUID4, isUUID5, toArray, toBigint, toBoolean, toDate, toDateString, toInteger, toNumber, toString, vg, };
|
|
62
|
+
export { isAlpha, isAlphanumeric, isAny, isArray, isAscii, isBase64, isBigint, isBoolean, isBtcAddress, isCreditCard, isDate, isDateString, isDecimal, isDefined, isEAN, isEmail, isEmpty, isETHAddress, isFQDN, isHex, isHexColor, isIBAN, isInteger, isIP, isIPRange, isISSN, isJWT, isLowercase, isMACAddress, isMobilePhone, isNotEmpty, isNotNull, isNotNullish, isNull, isNullish, isNumber, isObject, isObjectId, isPort, isString, isSWIFT, isUndefined, isUppercase, isURL, isUUID, isUUID1, isUUID2, isUUID3, isUUID4, isUUID5, toArray, toBigint, toBoolean, toDate, toDateString, toInteger, toNumber, toString, vg, };
|
|
@@ -7,17 +7,42 @@ export function isNull(options) {
|
|
|
7
7
|
return validator('isNull', (input, context, _this) => {
|
|
8
8
|
if (input === null)
|
|
9
9
|
return input;
|
|
10
|
-
context.fail(_this, `
|
|
10
|
+
context.fail(_this, `{{label}} is not null`, input);
|
|
11
|
+
}, options);
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Validates if value is not "null".
|
|
15
|
+
* @validator isNotNull
|
|
16
|
+
*/
|
|
17
|
+
export function isNotNull(options) {
|
|
18
|
+
return validator('isNotNull', (input, context, _this) => {
|
|
19
|
+
if (input !== null)
|
|
20
|
+
return input;
|
|
21
|
+
context.fail(_this, `{{label}} is null`, input);
|
|
11
22
|
}, options);
|
|
12
23
|
}
|
|
13
24
|
/**
|
|
14
25
|
* Validates if value is "null" or "undefined".
|
|
15
|
-
* @validator
|
|
26
|
+
* @validator isNullish
|
|
16
27
|
*/
|
|
17
28
|
export function isNullish(options) {
|
|
18
29
|
return validator('isNullish', (input, context, _this) => {
|
|
19
30
|
if (input == null)
|
|
20
31
|
return input;
|
|
21
|
-
context.fail(_this, `
|
|
32
|
+
context.fail(_this, `{{label}} is not nullish`, input);
|
|
33
|
+
}, options);
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Validates if value is not "null" nor "undefined".
|
|
37
|
+
* @validator isNotNullish
|
|
38
|
+
*/
|
|
39
|
+
export function isNotNullish(options) {
|
|
40
|
+
return validator('isNotNullish', (input, context, _this) => {
|
|
41
|
+
if (input != null)
|
|
42
|
+
return input;
|
|
43
|
+
if (input === null)
|
|
44
|
+
context.fail(_this, `{{label}} is null`, input);
|
|
45
|
+
else
|
|
46
|
+
context.fail(_this, `{{label}} is undefined`, input);
|
|
22
47
|
}, options);
|
|
23
48
|
}
|
package/package.json
CHANGED
package/typings/index.d.ts
CHANGED
|
@@ -12,7 +12,9 @@ declare const isEmpty: import("./core/validator.js").Validator<string | object |
|
|
|
12
12
|
declare const isNotEmpty: import("./core/validator.js").Validator<string | object | any[] | Set<any> | Map<any, any>, string | object | any[] | Set<any> | Map<any, any>, import("./core/types.js").ExecutionOptions>;
|
|
13
13
|
declare const isInteger: import("./core/validator.js").Validator<number, unknown, import("./core/types.js").ExecutionOptions>;
|
|
14
14
|
declare const isNull: import("./core/validator.js").Validator<null, unknown, import("./core/types.js").ExecutionOptions>;
|
|
15
|
+
declare const isNotNull: import("./core/validator.js").Validator<unknown, unknown, import("./core/types.js").ExecutionOptions>;
|
|
15
16
|
declare const isNullish: import("./core/validator.js").Validator<null, unknown, import("./core/types.js").ExecutionOptions>;
|
|
17
|
+
declare const isNotNullish: import("./core/validator.js").Validator<unknown, unknown, import("./core/types.js").ExecutionOptions>;
|
|
16
18
|
declare const isDefined: import("./core/validator.js").Validator<any, unknown, import("./core/types.js").ExecutionOptions>;
|
|
17
19
|
declare const isUndefined: import("./core/validator.js").Validator<any, unknown, import("./core/types.js").ExecutionOptions>;
|
|
18
20
|
declare const isNumber: import("./core/validator.js").Validator<number, unknown, import("./core/types.js").ExecutionOptions>;
|
|
@@ -58,4 +60,4 @@ declare const toDateString: import("./core/validator.js").Validator<string, stri
|
|
|
58
60
|
declare const toInteger: import("./core/validator.js").Validator<number, unknown, import("./core/types.js").ExecutionOptions>;
|
|
59
61
|
declare const toNumber: import("./core/validator.js").Validator<number, unknown, import("./core/types.js").ExecutionOptions>;
|
|
60
62
|
declare const toString: import("./core/validator.js").Validator<string, unknown, import("./core/types.js").ExecutionOptions>;
|
|
61
|
-
export { isAlpha, isAlphanumeric, isAny, isArray, isAscii, isBase64, isBigint, isBoolean, isBtcAddress, isCreditCard, isDate, isDateString, isDecimal, isDefined, isEAN, isEmail, isEmpty, isETHAddress, isFQDN, isHex, isHexColor, isIBAN, isInteger, isIP, isIPRange, isISSN, isJWT, isLowercase, isMACAddress, isMobilePhone, isNotEmpty, isNull, isNullish, isNumber, isObject, isObjectId, isPort, isString, isSWIFT, isUndefined, isUppercase, isURL, isUUID, isUUID1, isUUID2, isUUID3, isUUID4, isUUID5, toArray, toBigint, toBoolean, toDate, toDateString, toInteger, toNumber, toString, vg, };
|
|
63
|
+
export { isAlpha, isAlphanumeric, isAny, isArray, isAscii, isBase64, isBigint, isBoolean, isBtcAddress, isCreditCard, isDate, isDateString, isDecimal, isDefined, isEAN, isEmail, isEmpty, isETHAddress, isFQDN, isHex, isHexColor, isIBAN, isInteger, isIP, isIPRange, isISSN, isJWT, isLowercase, isMACAddress, isMobilePhone, isNotEmpty, isNotNull, isNotNullish, isNull, isNullish, isNumber, isObject, isObjectId, isPort, isString, isSWIFT, isUndefined, isUppercase, isURL, isUUID, isUUID1, isUUID2, isUUID3, isUUID4, isUUID5, toArray, toBigint, toBoolean, toDate, toDateString, toInteger, toNumber, toString, vg, };
|
|
@@ -4,8 +4,18 @@ import { ValidationOptions } from '../../core/index.js';
|
|
|
4
4
|
* @validator isNull
|
|
5
5
|
*/
|
|
6
6
|
export declare function isNull(options?: ValidationOptions): import("../../core/validator.js").Validator<null, unknown, import("../../core/types.js").ExecutionOptions>;
|
|
7
|
+
/**
|
|
8
|
+
* Validates if value is not "null".
|
|
9
|
+
* @validator isNotNull
|
|
10
|
+
*/
|
|
11
|
+
export declare function isNotNull(options?: ValidationOptions): import("../../core/validator.js").Validator<unknown, unknown, import("../../core/types.js").ExecutionOptions>;
|
|
7
12
|
/**
|
|
8
13
|
* Validates if value is "null" or "undefined".
|
|
9
|
-
* @validator
|
|
14
|
+
* @validator isNullish
|
|
10
15
|
*/
|
|
11
16
|
export declare function isNullish(options?: ValidationOptions): import("../../core/validator.js").Validator<null, unknown, import("../../core/types.js").ExecutionOptions>;
|
|
17
|
+
/**
|
|
18
|
+
* Validates if value is not "null" nor "undefined".
|
|
19
|
+
* @validator isNotNullish
|
|
20
|
+
*/
|
|
21
|
+
export declare function isNotNullish(options?: ValidationOptions): import("../../core/validator.js").Validator<unknown, unknown, import("../../core/types.js").ExecutionOptions>;
|