valgen 5.3.0 → 5.3.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 +9 -0
- package/cjs/core/context.js +2 -3
- package/cjs/core/validator.js +4 -4
- package/cjs/index.js +5 -5
- package/cjs/rules/format-rules/is-alpha.js +52 -0
- package/cjs/rules/format-rules/is-ascii.js +40 -0
- package/cjs/rules/format-rules/is-base64.js +40 -0
- package/cjs/rules/format-rules/is-btc-address.js +40 -0
- package/cjs/rules/format-rules/is-credit-card.js +40 -0
- package/cjs/rules/format-rules/is-decimal.js +41 -0
- package/cjs/rules/format-rules/is-ean.js +40 -0
- package/cjs/rules/format-rules/is-email.js +97 -0
- package/cjs/rules/format-rules/is-eth-address.js +40 -0
- package/cjs/rules/format-rules/is-fqdn.js +44 -0
- package/cjs/rules/format-rules/is-hash.js +40 -0
- package/cjs/rules/format-rules/is-hex-color.js +40 -0
- package/cjs/rules/format-rules/is-hex.js +40 -0
- package/cjs/rules/format-rules/is-iban.js +52 -0
- package/cjs/rules/format-rules/is-ip.js +52 -0
- package/cjs/rules/format-rules/is-issn.js +44 -0
- package/cjs/rules/format-rules/is-jwt.js +40 -0
- package/cjs/rules/format-rules/is-lowercase.js +52 -0
- package/cjs/rules/format-rules/is-mac-address.js +45 -0
- package/cjs/rules/format-rules/is-mobile-phone.js +43 -0
- package/cjs/rules/{is-object-id.js → format-rules/is-object-id.js} +3 -3
- package/cjs/rules/format-rules/is-passport-number.js +40 -0
- package/cjs/rules/format-rules/is-port.js +40 -0
- package/cjs/rules/format-rules/is-url.js +40 -0
- package/cjs/rules/format-rules/is-uuid.js +40 -0
- package/cjs/rules/format-rules/is-vat-number.js +40 -0
- package/cjs/rules/{is-regexp.js → format-rules/matches.js} +8 -5
- package/cjs/rules/index.js +49 -22
- package/cjs/rules/logical-rules/is-defined.js +30 -0
- package/cjs/rules/{is-empty.js → logical-rules/is-empty.js} +1 -1
- package/cjs/rules/{range.js → logical-rules/range.js} +63 -38
- package/cjs/rules/{is-any.js → type-rules/is-any.js} +1 -1
- package/cjs/rules/{is-array.js → type-rules/is-array.js} +2 -4
- package/cjs/rules/{is-bigint.js → type-rules/is-bigint.js} +2 -3
- package/cjs/rules/{is-boolean.js → type-rules/is-boolean.js} +1 -1
- package/cjs/rules/{is-date.js → type-rules/is-date.js} +5 -5
- package/cjs/rules/{is-enum.js → type-rules/is-enum.js} +6 -5
- package/cjs/rules/{is-integer.js → type-rules/is-integer.js} +2 -3
- package/cjs/rules/{is-null.js → type-rules/is-null.js} +2 -28
- package/cjs/rules/{is-number.js → type-rules/is-number.js} +2 -3
- package/cjs/rules/{is-object.js → type-rules/is-object.js} +3 -4
- package/cjs/rules/{is-record.js → type-rules/is-record.js} +1 -1
- package/cjs/rules/{is-string.js → type-rules/is-string.js} +1 -1
- package/cjs/rules/{is-tuple.js → type-rules/is-tuple.js} +2 -3
- package/cjs/rules/utility-rules/exists.js +16 -0
- package/cjs/rules/utility-rules/get-length.js +24 -0
- package/cjs/rules/utility-rules/optional.js +16 -0
- package/cjs/rules/{pipe.js → utility-rules/pipe.js} +1 -1
- package/cjs/rules/utility-rules/required.js +18 -0
- package/cjs/rules/{union.js → utility-rules/union.js} +2 -2
- package/esm/core/context.js +2 -3
- package/esm/core/validator.js +4 -4
- package/esm/index.js +3 -3
- package/esm/rules/format-rules/is-alpha.js +24 -0
- package/esm/rules/format-rules/is-ascii.js +13 -0
- package/esm/rules/format-rules/is-base64.js +13 -0
- package/esm/rules/format-rules/is-btc-address.js +13 -0
- package/esm/rules/format-rules/is-credit-card.js +13 -0
- package/esm/rules/format-rules/is-decimal.js +14 -0
- package/esm/rules/format-rules/is-ean.js +13 -0
- package/esm/rules/format-rules/is-email.js +70 -0
- package/esm/rules/format-rules/is-eth-address.js +13 -0
- package/esm/rules/format-rules/is-fqdn.js +17 -0
- package/esm/rules/format-rules/is-hash.js +13 -0
- package/esm/rules/format-rules/is-hex-color.js +13 -0
- package/esm/rules/format-rules/is-hex.js +13 -0
- package/esm/rules/format-rules/is-iban.js +24 -0
- package/esm/rules/format-rules/is-ip.js +24 -0
- package/esm/rules/format-rules/is-issn.js +17 -0
- package/esm/rules/format-rules/is-jwt.js +13 -0
- package/esm/rules/format-rules/is-lowercase.js +24 -0
- package/esm/rules/format-rules/is-mac-address.js +18 -0
- package/esm/rules/format-rules/is-mobile-phone.js +16 -0
- package/esm/rules/{is-object-id.js → format-rules/is-object-id.js} +3 -3
- package/esm/rules/format-rules/is-passport-number.js +13 -0
- package/esm/rules/format-rules/is-port.js +13 -0
- package/esm/rules/format-rules/is-url.js +13 -0
- package/esm/rules/format-rules/is-uuid.js +13 -0
- package/esm/rules/format-rules/is-vat-number.js +13 -0
- package/esm/rules/{is-regexp.js → format-rules/matches.js} +6 -3
- package/esm/rules/index.js +49 -22
- package/esm/rules/logical-rules/is-defined.js +25 -0
- package/esm/rules/{is-empty.js → logical-rules/is-empty.js} +1 -1
- package/esm/rules/{range.js → logical-rules/range.js} +59 -36
- package/esm/rules/{is-any.js → type-rules/is-any.js} +1 -1
- package/esm/rules/{is-array.js → type-rules/is-array.js} +2 -4
- package/esm/rules/{is-bigint.js → type-rules/is-bigint.js} +2 -3
- package/esm/rules/{is-boolean.js → type-rules/is-boolean.js} +1 -1
- package/esm/rules/{is-date.js → type-rules/is-date.js} +5 -5
- package/esm/rules/{is-enum.js → type-rules/is-enum.js} +6 -5
- package/esm/rules/{is-integer.js → type-rules/is-integer.js} +2 -3
- package/esm/rules/{is-null.js → type-rules/is-null.js} +1 -25
- package/esm/rules/{is-number.js → type-rules/is-number.js} +2 -3
- package/esm/rules/{is-object.js → type-rules/is-object.js} +3 -4
- package/esm/rules/{is-record.js → type-rules/is-record.js} +1 -1
- package/esm/rules/{is-string.js → type-rules/is-string.js} +1 -1
- package/esm/rules/{is-tuple.js → type-rules/is-tuple.js} +2 -3
- package/esm/rules/utility-rules/exists.js +12 -0
- package/esm/rules/utility-rules/get-length.js +20 -0
- package/esm/rules/utility-rules/optional.js +12 -0
- package/esm/rules/{pipe.js → utility-rules/pipe.js} +1 -1
- package/esm/rules/utility-rules/required.js +14 -0
- package/esm/rules/{union.js → utility-rules/union.js} +2 -2
- package/package.json +1 -1
- package/typings/index.d.ts +4 -4
- package/typings/rules/format-rules/is-alpha.d.ts +11 -0
- package/typings/rules/format-rules/is-ascii.d.ts +6 -0
- package/typings/rules/format-rules/is-base64.d.ts +9 -0
- package/typings/rules/format-rules/is-btc-address.d.ts +6 -0
- package/typings/rules/format-rules/is-credit-card.d.ts +9 -0
- package/typings/rules/format-rules/is-decimal.d.ts +7 -0
- package/typings/rules/format-rules/is-ean.d.ts +6 -0
- package/typings/rules/format-rules/is-email.d.ts +62 -0
- package/typings/rules/format-rules/is-eth-address.d.ts +6 -0
- package/typings/rules/format-rules/is-fqdn.d.ts +13 -0
- package/typings/rules/format-rules/is-hash.d.ts +8 -0
- package/typings/rules/format-rules/is-hex-color.d.ts +6 -0
- package/typings/rules/format-rules/is-hex.d.ts +6 -0
- package/typings/rules/format-rules/is-iban.d.ts +11 -0
- package/typings/rules/format-rules/is-ip.d.ts +11 -0
- package/typings/rules/format-rules/is-issn.d.ts +14 -0
- package/typings/rules/format-rules/is-jwt.d.ts +6 -0
- package/typings/rules/format-rules/is-lowercase.d.ts +11 -0
- package/typings/rules/format-rules/is-mac-address.d.ts +21 -0
- package/typings/rules/format-rules/is-mobile-phone.d.ts +20 -0
- package/typings/rules/{is-object-id.d.ts → format-rules/is-object-id.d.ts} +2 -2
- package/typings/rules/format-rules/is-passport-number.d.ts +6 -0
- package/typings/rules/format-rules/is-port.d.ts +6 -0
- package/typings/rules/format-rules/is-url.d.ts +9 -0
- package/typings/rules/format-rules/is-uuid.d.ts +6 -0
- package/typings/rules/format-rules/is-vat-number.d.ts +6 -0
- package/typings/rules/format-rules/matches.d.ts +9 -0
- package/typings/rules/index.d.ts +49 -22
- package/typings/rules/logical-rules/is-defined.d.ts +11 -0
- package/typings/rules/{is-empty.d.ts → logical-rules/is-empty.d.ts} +3 -3
- package/typings/rules/{range.d.ts → logical-rules/range.d.ts} +14 -4
- package/typings/rules/type-rules/is-any.d.ts +5 -0
- package/typings/rules/{is-array.d.ts → type-rules/is-array.d.ts} +2 -2
- package/typings/rules/{is-bigint.d.ts → type-rules/is-bigint.d.ts} +2 -2
- package/typings/rules/{is-boolean.d.ts → type-rules/is-boolean.d.ts} +2 -2
- package/typings/rules/{is-date.d.ts → type-rules/is-date.d.ts} +3 -3
- package/typings/rules/{is-enum.d.ts → type-rules/is-enum.d.ts} +1 -1
- package/typings/rules/{is-integer.d.ts → type-rules/is-integer.d.ts} +2 -2
- package/typings/rules/type-rules/is-null.d.ts +11 -0
- package/typings/rules/{is-number.d.ts → type-rules/is-number.d.ts} +2 -2
- package/typings/rules/{is-object.d.ts → type-rules/is-object.d.ts} +1 -1
- package/typings/rules/{is-record.d.ts → type-rules/is-record.d.ts} +2 -2
- package/typings/rules/{is-string.d.ts → type-rules/is-string.d.ts} +5 -5
- package/typings/rules/{is-tuple.d.ts → type-rules/is-tuple.d.ts} +2 -8
- package/typings/rules/utility-rules/exists.d.ts +6 -0
- package/typings/rules/utility-rules/get-length.d.ts +11 -0
- package/typings/rules/utility-rules/optional.d.ts +7 -0
- package/typings/rules/{pipe.d.ts → utility-rules/pipe.d.ts} +1 -1
- package/typings/rules/utility-rules/required.d.ts +7 -0
- package/typings/rules/utility-rules/union.d.ts +5 -0
- package/cjs/rules/length.js +0 -41
- package/cjs/rules/optional.js +0 -44
- package/cjs/rules/string-formats.js +0 -377
- package/esm/rules/length.js +0 -35
- package/esm/rules/optional.js +0 -38
- package/esm/rules/string-formats.js +0 -322
- package/typings/rules/is-any.d.ts +0 -5
- package/typings/rules/is-null.d.ts +0 -21
- package/typings/rules/is-regexp.d.ts +0 -9
- package/typings/rules/length.d.ts +0 -21
- package/typings/rules/optional.d.ts +0 -17
- package/typings/rules/string-formats.d.ts +0 -166
- package/typings/rules/union.d.ts +0 -5
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,12 @@
|
|
|
1
|
+
# v5.3.1
|
|
2
|
+
[2024-05-18]
|
|
3
|
+
|
|
4
|
+
### Changes
|
|
5
|
+
|
|
6
|
+
* Reorganized many rules ([`e470fe7`](https://github.com/panates/valgen/commit/e470fe7b99dc23378253c6e549d1df7c219fbbc9))
|
|
7
|
+
* Updated code documentation ([`81e7ccf`](https://github.com/panates/valgen/commit/81e7ccf145075a0649cb7281062f422cd989dfa3))
|
|
8
|
+
* Fixed rule name ([`73d90d1`](https://github.com/panates/valgen/commit/73d90d14314d6d98d089c60134f05d651a2e4b0f))
|
|
9
|
+
|
|
1
10
|
# v5.3.0
|
|
2
11
|
[2024-05-06]
|
|
3
12
|
|
package/cjs/core/context.js
CHANGED
|
@@ -22,7 +22,7 @@ class Context {
|
|
|
22
22
|
index: this.index,
|
|
23
23
|
label: this.label,
|
|
24
24
|
value,
|
|
25
|
-
...details
|
|
25
|
+
...details,
|
|
26
26
|
});
|
|
27
27
|
issue.value = value;
|
|
28
28
|
const onFail = this.onFail || rule[constants_js_1.kOptions].onFail;
|
|
@@ -37,8 +37,7 @@ class Context {
|
|
|
37
37
|
else
|
|
38
38
|
issue.message = String(x);
|
|
39
39
|
}
|
|
40
|
-
issue.message = ('' + issue.message)
|
|
41
|
-
.replace(VARIABLE_REPLACE_PATTERN, (x, g) => {
|
|
40
|
+
issue.message = ('' + issue.message).replace(VARIABLE_REPLACE_PATTERN, (x, g) => {
|
|
42
41
|
const m = OPTIONAL_VAR_PATTERN.exec(g);
|
|
43
42
|
if (!m)
|
|
44
43
|
return x;
|
package/cjs/core/validator.js
CHANGED
|
@@ -22,10 +22,10 @@ function validator(arg0, arg1, arg2) {
|
|
|
22
22
|
throw new TypeError('You must provide a rule function argument');
|
|
23
23
|
id = id || fn.name || 'unnamed-rule';
|
|
24
24
|
const name = fn.name || (0, string_utils_js_1.camelCase)(id);
|
|
25
|
-
const _rule =
|
|
25
|
+
const _rule = {
|
|
26
26
|
[name](input, options) {
|
|
27
27
|
const ctx = options instanceof context_js_1.Context ? options : undefined;
|
|
28
|
-
const opts =
|
|
28
|
+
const opts = ctx ? undefined : options;
|
|
29
29
|
const context = ctx || new context_js_1.Context(opts);
|
|
30
30
|
let value;
|
|
31
31
|
try {
|
|
@@ -39,8 +39,8 @@ function validator(arg0, arg1, arg2) {
|
|
|
39
39
|
if (!ctx && context.errors.length)
|
|
40
40
|
throw new validation_error_js_1.ValidationError(context.errors);
|
|
41
41
|
return value;
|
|
42
|
-
}
|
|
43
|
-
}
|
|
42
|
+
},
|
|
43
|
+
}[name];
|
|
44
44
|
_rule.id = id;
|
|
45
45
|
_rule[constants_js_1.kValidatorFn] = fn;
|
|
46
46
|
_rule[constants_js_1.kOptions] = validatorOptions || {};
|
package/cjs/index.js
CHANGED
|
@@ -26,7 +26,7 @@ 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.toArray = exports.
|
|
29
|
+
exports.toArray = exports.isHex = exports.isDecimal = exports.isAscii = exports.isAlphanumeric = exports.isAlpha = exports.isUppercase = exports.isLowercase = exports.isJWT = exports.isHexColor = exports.isETHAddress = exports.isBtcAddress = exports.isISSN = exports.isFQDN = exports.isEAN = exports.isIBAN = exports.isCreditCard = exports.isSWIFT = exports.isBase64 = exports.isURL = exports.isPort = exports.isMACAddress = exports.isIPRange = exports.isIP = exports.isMobilePhone = exports.isEmail = exports.isUUID5 = exports.isUUID4 = exports.isUUID3 = exports.isUUID2 = exports.isUUID1 = exports.isUUID = exports.isString = exports.isObjectId = exports.isObject = exports.isNumber = exports.isUndefined = exports.isDefined = exports.isNullish = exports.isNull = exports.isInteger = exports.isNotEmpty = exports.isEmpty = exports.isDateString = exports.isDate = exports.isBoolean = exports.isBigint = exports.isArray = exports.isAny = exports.vg = void 0;
|
|
30
30
|
exports.toString = exports.toNumber = exports.toInteger = exports.toDateString = exports.toDate = exports.toBoolean = void 0;
|
|
31
31
|
const vg = __importStar(require("./rules/index.js"));
|
|
32
32
|
exports.vg = vg;
|
|
@@ -94,8 +94,8 @@ const isURL = vg.isURL();
|
|
|
94
94
|
exports.isURL = isURL;
|
|
95
95
|
const isBase64 = vg.isBase64();
|
|
96
96
|
exports.isBase64 = isBase64;
|
|
97
|
-
const
|
|
98
|
-
exports.
|
|
97
|
+
const isSWIFT = vg.isSWIFT();
|
|
98
|
+
exports.isSWIFT = isSWIFT;
|
|
99
99
|
const isCreditCard = vg.isCreditCard();
|
|
100
100
|
exports.isCreditCard = isCreditCard;
|
|
101
101
|
const isIBAN = vg.isIBAN();
|
|
@@ -126,8 +126,8 @@ const isAscii = vg.isAscii();
|
|
|
126
126
|
exports.isAscii = isAscii;
|
|
127
127
|
const isDecimal = vg.isDecimal();
|
|
128
128
|
exports.isDecimal = isDecimal;
|
|
129
|
-
const
|
|
130
|
-
exports.
|
|
129
|
+
const isHex = vg.isHex();
|
|
130
|
+
exports.isHex = isHex;
|
|
131
131
|
const toArray = vg.isArray(isAny, { coerce: true });
|
|
132
132
|
exports.toArray = toArray;
|
|
133
133
|
const toBoolean = vg.isBoolean({ coerce: true });
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
+
exports.isAlphanumeric = exports.isAlpha = void 0;
|
|
27
|
+
const validatorJS = __importStar(require("validator"));
|
|
28
|
+
const index_js_1 = require("../../core/index.js");
|
|
29
|
+
/**
|
|
30
|
+
* Check if the string contains only letters (a-zA-Z).
|
|
31
|
+
* @validator isAlpha
|
|
32
|
+
*/
|
|
33
|
+
function isAlpha(options) {
|
|
34
|
+
return (0, index_js_1.validator)('isLowercase', function (input, context, _this) {
|
|
35
|
+
if (typeof input === 'string' && validatorJS.isAlpha(input))
|
|
36
|
+
return input;
|
|
37
|
+
context.fail(_this, `"{{value}}" is not an alpha string`, input);
|
|
38
|
+
}, options);
|
|
39
|
+
}
|
|
40
|
+
exports.isAlpha = isAlpha;
|
|
41
|
+
/**
|
|
42
|
+
* Check if the string contains only letters and numbers.
|
|
43
|
+
* @validator isAlphanumeric
|
|
44
|
+
*/
|
|
45
|
+
function isAlphanumeric(options) {
|
|
46
|
+
return (0, index_js_1.validator)('isAlphanumeric', function (input, context, _this) {
|
|
47
|
+
if (typeof input === 'string' && validatorJS.isAlphanumeric(input))
|
|
48
|
+
return input;
|
|
49
|
+
context.fail(_this, `"{{value}}" is not an alphanumeric string`, input);
|
|
50
|
+
}, options);
|
|
51
|
+
}
|
|
52
|
+
exports.isAlphanumeric = isAlphanumeric;
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
+
exports.isAscii = void 0;
|
|
27
|
+
const validatorJS = __importStar(require("validator"));
|
|
28
|
+
const index_js_1 = require("../../core/index.js");
|
|
29
|
+
/**
|
|
30
|
+
* Check if the string contains ASCII chars only.
|
|
31
|
+
* @validator isAscii
|
|
32
|
+
*/
|
|
33
|
+
function isAscii(options) {
|
|
34
|
+
return (0, index_js_1.validator)('isAscii', function (input, context, _this) {
|
|
35
|
+
if (typeof input === 'string' && validatorJS.isAscii(input))
|
|
36
|
+
return input;
|
|
37
|
+
context.fail(_this, `Value is not an ascii string`, input);
|
|
38
|
+
}, options);
|
|
39
|
+
}
|
|
40
|
+
exports.isAscii = isAscii;
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
+
exports.isBase64 = void 0;
|
|
27
|
+
const validatorJS = __importStar(require("validator"));
|
|
28
|
+
const index_js_1 = require("../../core/index.js");
|
|
29
|
+
/**
|
|
30
|
+
* Validates if value is a "Base64" string.
|
|
31
|
+
* @validator isBase64
|
|
32
|
+
*/
|
|
33
|
+
function isBase64(options) {
|
|
34
|
+
return (0, index_js_1.validator)('isBase64', function (input, context, _this) {
|
|
35
|
+
if (typeof input === 'string' && validatorJS.isBase64(input, options))
|
|
36
|
+
return input;
|
|
37
|
+
context.fail(_this, `"{{value}}" is not a valid a Base64 string`, input);
|
|
38
|
+
}, options);
|
|
39
|
+
}
|
|
40
|
+
exports.isBase64 = isBase64;
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
+
exports.isBtcAddress = void 0;
|
|
27
|
+
const validatorJS = __importStar(require("validator"));
|
|
28
|
+
const index_js_1 = require("../../core/index.js");
|
|
29
|
+
/**
|
|
30
|
+
* Validates if value is a BTC address.
|
|
31
|
+
* @validator isBtcAddress
|
|
32
|
+
*/
|
|
33
|
+
function isBtcAddress(options) {
|
|
34
|
+
return (0, index_js_1.validator)('isBtcAddress', function (input, context, _this) {
|
|
35
|
+
if (typeof input === 'string' && validatorJS.isBtcAddress(input))
|
|
36
|
+
return input;
|
|
37
|
+
context.fail(_this, `Value is not a valid a BTC address`, input);
|
|
38
|
+
}, options);
|
|
39
|
+
}
|
|
40
|
+
exports.isBtcAddress = isBtcAddress;
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
+
exports.isCreditCard = void 0;
|
|
27
|
+
const validatorJS = __importStar(require("validator"));
|
|
28
|
+
const index_js_1 = require("../../core/index.js");
|
|
29
|
+
/**
|
|
30
|
+
* Validates if value is a credit card number
|
|
31
|
+
* @validator isCreditCard
|
|
32
|
+
*/
|
|
33
|
+
function isCreditCard(options) {
|
|
34
|
+
return (0, index_js_1.validator)('isCreditCard', function (input, context, _this) {
|
|
35
|
+
if (typeof input === 'string' && validatorJS.isCreditCard(input, options))
|
|
36
|
+
return input;
|
|
37
|
+
context.fail(_this, `"{{value}}" is not a valid Credit Card number`, input);
|
|
38
|
+
}, options);
|
|
39
|
+
}
|
|
40
|
+
exports.isCreditCard = isCreditCard;
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
+
exports.isDecimal = void 0;
|
|
27
|
+
const validatorJS = __importStar(require("validator"));
|
|
28
|
+
const index_js_1 = require("../../core/index.js");
|
|
29
|
+
/**
|
|
30
|
+
* Check if the string represents a decimal number,
|
|
31
|
+
* such as `0.1`, `.3`, `1.1`, `1.00003`, `4.0` etc.
|
|
32
|
+
* @validator isDecimal
|
|
33
|
+
*/
|
|
34
|
+
function isDecimal(options) {
|
|
35
|
+
return (0, index_js_1.validator)('isDecimal', function (input, context, _this) {
|
|
36
|
+
if (typeof input === 'string' && validatorJS.isDecimal(input))
|
|
37
|
+
return input;
|
|
38
|
+
context.fail(_this, `"{{value}}" is not an decimal number string`, input);
|
|
39
|
+
}, options);
|
|
40
|
+
}
|
|
41
|
+
exports.isDecimal = isDecimal;
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
+
exports.isEAN = void 0;
|
|
27
|
+
const validatorJS = __importStar(require("validator"));
|
|
28
|
+
const index_js_1 = require("../../core/index.js");
|
|
29
|
+
/**
|
|
30
|
+
* Validates if value is an EAN (European Article Number)
|
|
31
|
+
* @validator isEAN
|
|
32
|
+
*/
|
|
33
|
+
function isEAN(options) {
|
|
34
|
+
return (0, index_js_1.validator)('isEAN', function (input, context, _this) {
|
|
35
|
+
if (typeof input === 'string' && validatorJS.isEAN(input))
|
|
36
|
+
return input;
|
|
37
|
+
context.fail(_this, `"{{value}}" is not a valid EAN (European Article Number)`, input);
|
|
38
|
+
}, options);
|
|
39
|
+
}
|
|
40
|
+
exports.isEAN = isEAN;
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
+
exports.isEmail = void 0;
|
|
27
|
+
const validatorJS = __importStar(require("validator"));
|
|
28
|
+
const index_js_1 = require("../../core/index.js");
|
|
29
|
+
/**
|
|
30
|
+
* Validates if value is a valid Email
|
|
31
|
+
* @validator isEmail
|
|
32
|
+
*/
|
|
33
|
+
function isEmail(options) {
|
|
34
|
+
const emailOptions = {
|
|
35
|
+
// eslint-disable-next-line camelcase
|
|
36
|
+
allow_display_name: true,
|
|
37
|
+
// eslint-disable-next-line camelcase
|
|
38
|
+
allow_utf8_local_part: options?.utf8LocalPart,
|
|
39
|
+
// eslint-disable-next-line camelcase
|
|
40
|
+
ignore_max_length: true,
|
|
41
|
+
// eslint-disable-next-line camelcase
|
|
42
|
+
allow_ip_domain: options?.allowIpDomain,
|
|
43
|
+
};
|
|
44
|
+
return (0, index_js_1.validator)('isEmail', function (input, context, _this) {
|
|
45
|
+
if (typeof input === 'string' && validatorJS.isEmail(input, emailOptions)) {
|
|
46
|
+
if (options?.requireDisplayName) {
|
|
47
|
+
if (!validatorJS.isEmail(input, {
|
|
48
|
+
...emailOptions,
|
|
49
|
+
// eslint-disable-next-line camelcase
|
|
50
|
+
require_display_name: true,
|
|
51
|
+
})) {
|
|
52
|
+
context.fail(_this, `Display name for the email is required. Etc. ( Name <me@tempuri.org> ) `, input);
|
|
53
|
+
return;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
else if (!options?.allowDisplayName &&
|
|
57
|
+
!validatorJS.isEmail(input, {
|
|
58
|
+
...emailOptions,
|
|
59
|
+
// eslint-disable-next-line camelcase
|
|
60
|
+
allow_display_name: false,
|
|
61
|
+
})) {
|
|
62
|
+
context.fail(_this, `Display name in email is not allowed`, input);
|
|
63
|
+
return;
|
|
64
|
+
}
|
|
65
|
+
if (options?.hostBlacklist &&
|
|
66
|
+
!validatorJS.isEmail(input, {
|
|
67
|
+
...emailOptions,
|
|
68
|
+
// eslint-disable-next-line camelcase
|
|
69
|
+
host_blacklist: options.hostBlacklist,
|
|
70
|
+
})) {
|
|
71
|
+
context.fail(_this, `Email "{{value}}" is in black-list`, input);
|
|
72
|
+
return;
|
|
73
|
+
}
|
|
74
|
+
if (options?.hostWhitelist &&
|
|
75
|
+
!validatorJS.isEmail(input, {
|
|
76
|
+
...emailOptions,
|
|
77
|
+
// eslint-disable-next-line camelcase
|
|
78
|
+
host_whitelist: options.hostWhitelist,
|
|
79
|
+
})) {
|
|
80
|
+
context.fail(_this, `Email "{{value}}" is in not white-list`, input);
|
|
81
|
+
return;
|
|
82
|
+
}
|
|
83
|
+
if (options?.blacklistedChars &&
|
|
84
|
+
!validatorJS.isEmail(input, {
|
|
85
|
+
...emailOptions,
|
|
86
|
+
// eslint-disable-next-line camelcase
|
|
87
|
+
blacklisted_chars: options.blacklistedChars,
|
|
88
|
+
})) {
|
|
89
|
+
context.fail(_this, `Black listed characters (${options.blacklistedChars}) found in name part`, input);
|
|
90
|
+
return;
|
|
91
|
+
}
|
|
92
|
+
return input;
|
|
93
|
+
}
|
|
94
|
+
context.fail(_this, `"{{value}}" does not match required e-mail format`, input);
|
|
95
|
+
}, options);
|
|
96
|
+
}
|
|
97
|
+
exports.isEmail = isEmail;
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
+
exports.isETHAddress = void 0;
|
|
27
|
+
const validatorJS = __importStar(require("validator"));
|
|
28
|
+
const index_js_1 = require("../../core/index.js");
|
|
29
|
+
/**
|
|
30
|
+
* Validates if value is a ETH (Ethereum) address.
|
|
31
|
+
* @validator isETHAddress
|
|
32
|
+
*/
|
|
33
|
+
function isETHAddress(options) {
|
|
34
|
+
return (0, index_js_1.validator)('isETHAddress', function (input, context, _this) {
|
|
35
|
+
if (typeof input === 'string' && validatorJS.isEthereumAddress(input))
|
|
36
|
+
return input;
|
|
37
|
+
context.fail(_this, `Value is not a valid a ETH (Ethereum) address`, input);
|
|
38
|
+
}, options);
|
|
39
|
+
}
|
|
40
|
+
exports.isETHAddress = isETHAddress;
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
+
exports.isFQDN = void 0;
|
|
27
|
+
const validatorJS = __importStar(require("validator"));
|
|
28
|
+
const index_js_1 = require("../../core/index.js");
|
|
29
|
+
/**
|
|
30
|
+
* Validates if value is an FQDN
|
|
31
|
+
* @validator isFQDN
|
|
32
|
+
*/
|
|
33
|
+
function isFQDN(options) {
|
|
34
|
+
const opts = {
|
|
35
|
+
// eslint-disable-next-line camelcase
|
|
36
|
+
allow_wildcard: options?.allowWildcard,
|
|
37
|
+
};
|
|
38
|
+
return (0, index_js_1.validator)('isFQDN', function (input, context, _this) {
|
|
39
|
+
if (typeof input === 'string' && validatorJS.isFQDN(input, opts))
|
|
40
|
+
return input;
|
|
41
|
+
context.fail(_this, `"{{value}}" is not valid FQDN`, input);
|
|
42
|
+
}, options);
|
|
43
|
+
}
|
|
44
|
+
exports.isFQDN = isFQDN;
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
+
exports.isHash = void 0;
|
|
27
|
+
const validatorJS = __importStar(require("validator"));
|
|
28
|
+
const index_js_1 = require("../../core/index.js");
|
|
29
|
+
/**
|
|
30
|
+
* Validates if value a hash of type algorithm
|
|
31
|
+
* @validator isHash
|
|
32
|
+
*/
|
|
33
|
+
function isHash(algorithm, options) {
|
|
34
|
+
return (0, index_js_1.validator)('isHash', function (input, context, _this) {
|
|
35
|
+
if (typeof input === 'string' && validatorJS.isHash(input, algorithm))
|
|
36
|
+
return input;
|
|
37
|
+
context.fail(_this, `Value is not a valid ${algorithm} hash`, input);
|
|
38
|
+
}, options);
|
|
39
|
+
}
|
|
40
|
+
exports.isHash = isHash;
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
+
exports.isHexColor = void 0;
|
|
27
|
+
const validatorJS = __importStar(require("validator"));
|
|
28
|
+
const index_js_1 = require("../../core/index.js");
|
|
29
|
+
/**
|
|
30
|
+
* Validates if value is a Hex Color
|
|
31
|
+
* @validator isHexColor
|
|
32
|
+
*/
|
|
33
|
+
function isHexColor(options) {
|
|
34
|
+
return (0, index_js_1.validator)('isHexColor', function (input, context, _this) {
|
|
35
|
+
if (typeof input === 'string' && validatorJS.isHexColor(input))
|
|
36
|
+
return input;
|
|
37
|
+
context.fail(_this, `{{label}} is not a valid Hex Color`, input);
|
|
38
|
+
}, options);
|
|
39
|
+
}
|
|
40
|
+
exports.isHexColor = isHexColor;
|