valgen 5.7.0 → 5.8.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 +14 -0
- package/cjs/package.json +3 -0
- package/esm/constants.js +2 -5
- package/esm/core/constants.js +2 -5
- package/esm/core/context.js +5 -9
- package/esm/core/index.js +6 -9
- package/esm/core/types.js +1 -2
- package/esm/core/utilities.js +6 -10
- package/esm/core/validation-error.js +1 -5
- package/esm/core/validator.js +14 -18
- package/esm/factories.js +1 -4
- package/esm/helpers/object.utils.js +2 -6
- package/esm/helpers/omit-undefined.js +1 -4
- package/esm/helpers/string.utils.js +1 -4
- package/esm/index.js +4 -67
- package/esm/package.json +3 -0
- package/esm/rules/format-rules/is-alpha.js +6 -11
- package/esm/rules/format-rules/is-ascii.js +4 -8
- package/esm/rules/format-rules/is-base64.js +4 -8
- package/esm/rules/format-rules/is-btc-address.js +4 -8
- package/esm/rules/format-rules/is-credit-card.js +4 -8
- package/esm/rules/format-rules/is-decimal.js +4 -8
- package/esm/rules/format-rules/is-ean.js +4 -8
- package/esm/rules/format-rules/is-email.js +4 -8
- package/esm/rules/format-rules/is-eth-address.js +4 -8
- package/esm/rules/format-rules/is-fqdn.js +4 -8
- package/esm/rules/format-rules/is-hash.js +4 -8
- package/esm/rules/format-rules/is-hex-color.js +4 -8
- package/esm/rules/format-rules/is-hex.js +4 -8
- package/esm/rules/format-rules/is-iban.js +6 -11
- package/esm/rules/format-rules/is-ip.js +6 -11
- package/esm/rules/format-rules/is-issn.js +4 -8
- package/esm/rules/format-rules/is-jwt.js +4 -8
- package/esm/rules/format-rules/is-lowercase.js +6 -11
- package/esm/rules/format-rules/is-mac-address.js +4 -8
- package/esm/rules/format-rules/is-mobile-phone.js +4 -8
- package/esm/rules/format-rules/is-object-id.js +5 -9
- package/esm/rules/format-rules/is-passport-number.js +4 -8
- package/esm/rules/format-rules/is-port.js +4 -8
- package/esm/rules/format-rules/is-url.js +4 -8
- package/esm/rules/format-rules/is-uuid.js +4 -8
- package/esm/rules/format-rules/is-vat-number.js +4 -8
- package/esm/rules/format-rules/matches.js +3 -6
- package/esm/rules/index.js +50 -53
- package/esm/rules/logical-rules/is-defined.js +3 -6
- package/esm/rules/logical-rules/is-empty.js +5 -9
- package/esm/rules/logical-rules/range.js +19 -29
- package/esm/rules/type-rules/is-any.js +2 -6
- package/esm/rules/type-rules/is-array.js +3 -6
- package/esm/rules/type-rules/is-bigint.js +3 -6
- package/esm/rules/type-rules/is-boolean.js +3 -6
- package/esm/rules/type-rules/is-date.js +10 -14
- package/esm/rules/type-rules/is-enum.js +3 -6
- package/esm/rules/type-rules/is-integer.js +3 -6
- package/esm/rules/type-rules/is-null.js +9 -15
- package/esm/rules/type-rules/is-number.js +3 -6
- package/esm/rules/type-rules/is-object.js +11 -14
- package/esm/rules/type-rules/is-record.js +3 -6
- package/esm/rules/type-rules/is-string.js +13 -22
- package/esm/rules/type-rules/is-tuple.js +3 -6
- package/esm/rules/type-rules/is-undefined.js +3 -6
- package/esm/rules/utility-rules/exists.js +3 -6
- package/esm/rules/utility-rules/get-length.js +3 -6
- package/esm/rules/utility-rules/optional.js +3 -6
- package/esm/rules/utility-rules/pipe.js +5 -9
- package/esm/rules/utility-rules/required.js +3 -6
- package/esm/rules/utility-rules/union.js +3 -6
- package/package.json +13 -9
- package/types/core/context.d.ts +1 -1
- package/types/core/types.d.ts +1 -1
|
@@ -1,15 +1,11 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
exports.isHash = isHash;
|
|
4
|
-
const tslib_1 = require("tslib");
|
|
5
|
-
const validatorJS = tslib_1.__importStar(require("validator"));
|
|
6
|
-
const index_js_1 = require("../../core/index.js");
|
|
1
|
+
import * as validatorJS from 'validator';
|
|
2
|
+
import { validator } from '../../core/index.js';
|
|
7
3
|
/**
|
|
8
4
|
* Validates if value a hash of type algorithm
|
|
9
5
|
* @validator isHash
|
|
10
6
|
*/
|
|
11
|
-
function isHash(algorithm, options) {
|
|
12
|
-
return
|
|
7
|
+
export function isHash(algorithm, options) {
|
|
8
|
+
return validator('isHash', (input, context, _this) => {
|
|
13
9
|
if (typeof input === 'string' && validatorJS.isHash(input, algorithm)) {
|
|
14
10
|
return input;
|
|
15
11
|
}
|
|
@@ -1,15 +1,11 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
exports.isHexColor = isHexColor;
|
|
4
|
-
const tslib_1 = require("tslib");
|
|
5
|
-
const validatorJS = tslib_1.__importStar(require("validator"));
|
|
6
|
-
const index_js_1 = require("../../core/index.js");
|
|
1
|
+
import * as validatorJS from 'validator';
|
|
2
|
+
import { validator } from '../../core/index.js';
|
|
7
3
|
/**
|
|
8
4
|
* Validates if value is a Hex Color
|
|
9
5
|
* @validator isHexColor
|
|
10
6
|
*/
|
|
11
|
-
function isHexColor(options) {
|
|
12
|
-
return
|
|
7
|
+
export function isHexColor(options) {
|
|
8
|
+
return validator('isHexColor', (input, context, _this) => {
|
|
13
9
|
if (typeof input === 'string' && validatorJS.isHexColor(input)) {
|
|
14
10
|
return input;
|
|
15
11
|
}
|
|
@@ -1,15 +1,11 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
exports.isHex = isHex;
|
|
4
|
-
const tslib_1 = require("tslib");
|
|
5
|
-
const validatorJS = tslib_1.__importStar(require("validator"));
|
|
6
|
-
const index_js_1 = require("../../core/index.js");
|
|
1
|
+
import * as validatorJS from 'validator';
|
|
2
|
+
import { validator } from '../../core/index.js';
|
|
7
3
|
/**
|
|
8
4
|
* Check if the string is a hexadecimal number.
|
|
9
5
|
* @validator isHex
|
|
10
6
|
*/
|
|
11
|
-
function isHex(options) {
|
|
12
|
-
return
|
|
7
|
+
export function isHex(options) {
|
|
8
|
+
return validator('isHex', (input, context, _this) => {
|
|
13
9
|
if (typeof input === 'string' && validatorJS.isHexadecimal(input)) {
|
|
14
10
|
return input;
|
|
15
11
|
}
|
|
@@ -1,16 +1,11 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
exports.isIBAN = isIBAN;
|
|
4
|
-
exports.isSWIFT = isSWIFT;
|
|
5
|
-
const tslib_1 = require("tslib");
|
|
6
|
-
const validatorJS = tslib_1.__importStar(require("validator"));
|
|
7
|
-
const index_js_1 = require("../../core/index.js");
|
|
1
|
+
import * as validatorJS from 'validator';
|
|
2
|
+
import { validator } from '../../core/index.js';
|
|
8
3
|
/**
|
|
9
4
|
* Validates if value is an IBAN (International Bank Account Number)
|
|
10
5
|
* @validator isIBAN
|
|
11
6
|
*/
|
|
12
|
-
function isIBAN(options) {
|
|
13
|
-
return
|
|
7
|
+
export function isIBAN(options) {
|
|
8
|
+
return validator('isIBAN', (input, context, _this) => {
|
|
14
9
|
if (typeof input === 'string' && validatorJS.isIBAN(input))
|
|
15
10
|
return input;
|
|
16
11
|
context.fail(_this, `{{label}} is not a valid IBAN (International Bank Account Number)`, input);
|
|
@@ -20,8 +15,8 @@ function isIBAN(options) {
|
|
|
20
15
|
* Validates if value is a BIC (Bank Identification Code) or SWIFT code
|
|
21
16
|
* @validator isSWIFT
|
|
22
17
|
*/
|
|
23
|
-
function isSWIFT(options) {
|
|
24
|
-
return
|
|
18
|
+
export function isSWIFT(options) {
|
|
19
|
+
return validator('isSWIFT', (input, context, _this) => {
|
|
25
20
|
if (typeof input === 'string' && validatorJS.isBIC(input))
|
|
26
21
|
return input;
|
|
27
22
|
context.fail(_this, `{{label}}is not a valid a BIC (Bank Identification Code) or SWIFT code`, input);
|
|
@@ -1,16 +1,11 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
exports.isIP = isIP;
|
|
4
|
-
exports.isIPRange = isIPRange;
|
|
5
|
-
const tslib_1 = require("tslib");
|
|
6
|
-
const validatorJS = tslib_1.__importStar(require("validator"));
|
|
7
|
-
const index_js_1 = require("../../core/index.js");
|
|
1
|
+
import * as validatorJS from 'validator';
|
|
2
|
+
import { validator } from '../../core/index.js';
|
|
8
3
|
/**
|
|
9
4
|
* Validates if value is an IP
|
|
10
5
|
* @validator isIP
|
|
11
6
|
*/
|
|
12
|
-
function isIP(version, options) {
|
|
13
|
-
return
|
|
7
|
+
export function isIP(version, options) {
|
|
8
|
+
return validator('isIP', (input, context, _this) => {
|
|
14
9
|
if (input != null &&
|
|
15
10
|
typeof input === 'string' &&
|
|
16
11
|
validatorJS.isIP(input, version)) {
|
|
@@ -23,8 +18,8 @@ function isIP(version, options) {
|
|
|
23
18
|
* Validates if value is an IP
|
|
24
19
|
* @validator isIPRange
|
|
25
20
|
*/
|
|
26
|
-
function isIPRange(version, options) {
|
|
27
|
-
return
|
|
21
|
+
export function isIPRange(version, options) {
|
|
22
|
+
return validator('isIPRange', (input, context, _this) => {
|
|
28
23
|
if (input != null &&
|
|
29
24
|
typeof input === 'string' &&
|
|
30
25
|
validatorJS.isIPRange(input, version)) {
|
|
@@ -1,19 +1,15 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
exports.isISSN = isISSN;
|
|
4
|
-
const tslib_1 = require("tslib");
|
|
5
|
-
const validatorJS = tslib_1.__importStar(require("validator"));
|
|
6
|
-
const index_js_1 = require("../../core/index.js");
|
|
1
|
+
import * as validatorJS from 'validator';
|
|
2
|
+
import { validator } from '../../core/index.js';
|
|
7
3
|
/**
|
|
8
4
|
* Validates if value is an ISSN
|
|
9
5
|
* @validator isISSN
|
|
10
6
|
*/
|
|
11
|
-
function isISSN(options) {
|
|
7
|
+
export function isISSN(options) {
|
|
12
8
|
const opts = {
|
|
13
9
|
// eslint-disable-next-line camelcase
|
|
14
10
|
case_sensitive: options?.caseSensitive,
|
|
15
11
|
};
|
|
16
|
-
return
|
|
12
|
+
return validator('isISSN', (input, context, _this) => {
|
|
17
13
|
if (typeof input === 'string' && validatorJS.isISSN(input, opts)) {
|
|
18
14
|
return input;
|
|
19
15
|
}
|
|
@@ -1,15 +1,11 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
exports.isJWT = isJWT;
|
|
4
|
-
const tslib_1 = require("tslib");
|
|
5
|
-
const validatorJS = tslib_1.__importStar(require("validator"));
|
|
6
|
-
const index_js_1 = require("../../core/index.js");
|
|
1
|
+
import * as validatorJS from 'validator';
|
|
2
|
+
import { validator } from '../../core/index.js';
|
|
7
3
|
/**
|
|
8
4
|
* Validates if value a valid JWT token
|
|
9
5
|
* @validator isJWT
|
|
10
6
|
*/
|
|
11
|
-
function isJWT(options) {
|
|
12
|
-
return
|
|
7
|
+
export function isJWT(options) {
|
|
8
|
+
return validator('isJWT', (input, context, _this) => {
|
|
13
9
|
if (typeof input === 'string' && validatorJS.isJWT(input))
|
|
14
10
|
return input;
|
|
15
11
|
context.fail(_this, `Value is not a valid JWT token`, input);
|
|
@@ -1,16 +1,11 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
exports.isLowercase = isLowercase;
|
|
4
|
-
exports.isUppercase = isUppercase;
|
|
5
|
-
const tslib_1 = require("tslib");
|
|
6
|
-
const validatorJS = tslib_1.__importStar(require("validator"));
|
|
7
|
-
const index_js_1 = require("../../core/index.js");
|
|
1
|
+
import * as validatorJS from 'validator';
|
|
2
|
+
import { validator } from '../../core/index.js';
|
|
8
3
|
/**
|
|
9
4
|
* Validates if value a Lowercase string
|
|
10
5
|
* @validator isLowercase
|
|
11
6
|
*/
|
|
12
|
-
function isLowercase(options) {
|
|
13
|
-
return
|
|
7
|
+
export function isLowercase(options) {
|
|
8
|
+
return validator('isLowercase', (input, context, _this) => {
|
|
14
9
|
if (typeof input === 'string' && validatorJS.isLowercase(input)) {
|
|
15
10
|
return input;
|
|
16
11
|
}
|
|
@@ -21,8 +16,8 @@ function isLowercase(options) {
|
|
|
21
16
|
* Validates if value a Uppercase string
|
|
22
17
|
* @validator isUppercase
|
|
23
18
|
*/
|
|
24
|
-
function isUppercase(options) {
|
|
25
|
-
return
|
|
19
|
+
export function isUppercase(options) {
|
|
20
|
+
return validator('isUppercase', (input, context, _this) => {
|
|
26
21
|
if (typeof input === 'string' && validatorJS.isUppercase(input)) {
|
|
27
22
|
return input;
|
|
28
23
|
}
|
|
@@ -1,20 +1,16 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
exports.isMACAddress = isMACAddress;
|
|
4
|
-
const tslib_1 = require("tslib");
|
|
5
|
-
const validatorJS = tslib_1.__importStar(require("validator"));
|
|
6
|
-
const index_js_1 = require("../../core/index.js");
|
|
1
|
+
import * as validatorJS from 'validator';
|
|
2
|
+
import { validator } from '../../core/index.js';
|
|
7
3
|
/**
|
|
8
4
|
* Validates if value is an MACAddress
|
|
9
5
|
* @validator isMACAddress
|
|
10
6
|
*/
|
|
11
|
-
function isMACAddress(options) {
|
|
7
|
+
export function isMACAddress(options) {
|
|
12
8
|
const opts = {
|
|
13
9
|
// eslint-disable-next-line camelcase
|
|
14
10
|
no_separators: options?.noSeparators,
|
|
15
11
|
eui: options?.eui,
|
|
16
12
|
};
|
|
17
|
-
return
|
|
13
|
+
return validator('isMACAddress', (input, context, _this) => {
|
|
18
14
|
if (input != null &&
|
|
19
15
|
typeof input === 'string' &&
|
|
20
16
|
validatorJS.isMACAddress(input, opts)) {
|
|
@@ -1,18 +1,14 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
exports.isMobilePhone = isMobilePhone;
|
|
4
|
-
const tslib_1 = require("tslib");
|
|
5
|
-
const validatorJS = tslib_1.__importStar(require("validator"));
|
|
6
|
-
const index_js_1 = require("../../core/index.js");
|
|
1
|
+
import * as validatorJS from 'validator';
|
|
2
|
+
import { validator } from '../../core/index.js';
|
|
7
3
|
/**
|
|
8
4
|
* Validates if value is a valid Email
|
|
9
5
|
* @validator isMobilePhone
|
|
10
6
|
*/
|
|
11
|
-
function isMobilePhone(options) {
|
|
7
|
+
export function isMobilePhone(options) {
|
|
12
8
|
const opts = {
|
|
13
9
|
strictMode: options?.strictMode,
|
|
14
10
|
};
|
|
15
|
-
return
|
|
11
|
+
return validator('isMobilePhone', (input, context, _this) => {
|
|
16
12
|
if (typeof input === 'string' &&
|
|
17
13
|
validatorJS.isMobilePhone(input, options?.locale, opts)) {
|
|
18
14
|
return input;
|
|
@@ -1,15 +1,11 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
exports.isObjectId = isObjectId;
|
|
4
|
-
const tslib_1 = require("tslib");
|
|
5
|
-
const validator_1 = tslib_1.__importDefault(require("validator"));
|
|
6
|
-
const index_js_1 = require("../../core/index.js");
|
|
1
|
+
import validatorJS from 'validator';
|
|
2
|
+
import { validator, } from '../../core/index.js';
|
|
7
3
|
/**
|
|
8
4
|
* Validates if value is an "ObjectId".
|
|
9
5
|
* @validator isObjectId
|
|
10
6
|
*/
|
|
11
|
-
function isObjectId(options) {
|
|
12
|
-
return
|
|
7
|
+
export function isObjectId(options) {
|
|
8
|
+
return validator('isObjectId', (input, context, _this) => {
|
|
13
9
|
if (input != null &&
|
|
14
10
|
(_isObjectIdValue(input) ||
|
|
15
11
|
(typeof input === 'object' &&
|
|
@@ -24,5 +20,5 @@ function _isObjectIdValue(input) {
|
|
|
24
20
|
return ((input instanceof Uint8Array && input.length === 12) ||
|
|
25
21
|
(typeof input === 'string' &&
|
|
26
22
|
input.length === 24 &&
|
|
27
|
-
|
|
23
|
+
validatorJS.isHexadecimal(input)));
|
|
28
24
|
}
|
|
@@ -1,15 +1,11 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
exports.isPassportNumber = isPassportNumber;
|
|
4
|
-
const tslib_1 = require("tslib");
|
|
5
|
-
const validatorJS = tslib_1.__importStar(require("validator"));
|
|
6
|
-
const index_js_1 = require("../../core/index.js");
|
|
1
|
+
import * as validatorJS from 'validator';
|
|
2
|
+
import { validator } from '../../core/index.js';
|
|
7
3
|
/**
|
|
8
4
|
* Validates if value is a passport number
|
|
9
5
|
* @validator isPassportNumber
|
|
10
6
|
*/
|
|
11
|
-
function isPassportNumber(countryCode, options) {
|
|
12
|
-
return
|
|
7
|
+
export function isPassportNumber(countryCode, options) {
|
|
8
|
+
return validator('isPassportNumber', (input, context, _this) => {
|
|
13
9
|
if (typeof input === 'string' &&
|
|
14
10
|
validatorJS.isPassportNumber(input, countryCode)) {
|
|
15
11
|
return input;
|
|
@@ -1,15 +1,11 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
exports.isPort = isPort;
|
|
4
|
-
const tslib_1 = require("tslib");
|
|
5
|
-
const validatorJS = tslib_1.__importStar(require("validator"));
|
|
6
|
-
const index_js_1 = require("../../core/index.js");
|
|
1
|
+
import * as validatorJS from 'validator';
|
|
2
|
+
import { validator } from '../../core/index.js';
|
|
7
3
|
/**
|
|
8
4
|
* Validates if value is a port number
|
|
9
5
|
* @validator isPort
|
|
10
6
|
*/
|
|
11
|
-
function isPort(options) {
|
|
12
|
-
return
|
|
7
|
+
export function isPort(options) {
|
|
8
|
+
return validator('isPort', (input, context, _this) => {
|
|
13
9
|
if (input != null &&
|
|
14
10
|
typeof input === 'string' &&
|
|
15
11
|
validatorJS.isPort(input)) {
|
|
@@ -1,15 +1,11 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
exports.isURL = isURL;
|
|
4
|
-
const tslib_1 = require("tslib");
|
|
5
|
-
const validatorJS = tslib_1.__importStar(require("validator"));
|
|
6
|
-
const index_js_1 = require("../../core/index.js");
|
|
1
|
+
import * as validatorJS from 'validator';
|
|
2
|
+
import { validator } from '../../core/index.js';
|
|
7
3
|
/**
|
|
8
4
|
* Validates if value is an URL
|
|
9
5
|
* @validator isURL
|
|
10
6
|
*/
|
|
11
|
-
function isURL(options) {
|
|
12
|
-
return
|
|
7
|
+
export function isURL(options) {
|
|
8
|
+
return validator('isURL', (input, context, _this) => {
|
|
13
9
|
if (input != null &&
|
|
14
10
|
typeof input === 'string' &&
|
|
15
11
|
validatorJS.isURL(input, options)) {
|
|
@@ -1,15 +1,11 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
exports.isUUID = isUUID;
|
|
4
|
-
const tslib_1 = require("tslib");
|
|
5
|
-
const validatorJS = tslib_1.__importStar(require("validator"));
|
|
6
|
-
const index_js_1 = require("../../core/index.js");
|
|
1
|
+
import * as validatorJS from 'validator';
|
|
2
|
+
import { validator } from '../../core/index.js';
|
|
7
3
|
/**
|
|
8
4
|
* Validates if value is an "UUID".
|
|
9
5
|
* @validator isUUID
|
|
10
6
|
*/
|
|
11
|
-
function isUUID(version, options) {
|
|
12
|
-
return
|
|
7
|
+
export function isUUID(version, options) {
|
|
8
|
+
return validator('isUUID', (input, context, _this) => {
|
|
13
9
|
if (input != null &&
|
|
14
10
|
typeof input === 'string' &&
|
|
15
11
|
validatorJS.isUUID(input, version)) {
|
|
@@ -1,15 +1,11 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
exports.isVATNumber = isVATNumber;
|
|
4
|
-
const tslib_1 = require("tslib");
|
|
5
|
-
const validatorJS = tslib_1.__importStar(require("validator"));
|
|
6
|
-
const index_js_1 = require("../../core/index.js");
|
|
1
|
+
import * as validatorJS from 'validator';
|
|
2
|
+
import { validator } from '../../core/index.js';
|
|
7
3
|
/**
|
|
8
4
|
* Validates if value is an VAT number
|
|
9
5
|
* @validator isVAT
|
|
10
6
|
*/
|
|
11
|
-
function isVATNumber(countryCode, options) {
|
|
12
|
-
return
|
|
7
|
+
export function isVATNumber(countryCode, options) {
|
|
8
|
+
return validator('isVATNumber', (input, context, _this) => {
|
|
13
9
|
if (typeof input === 'string' && validatorJS.isVAT(input, countryCode)) {
|
|
14
10
|
return input;
|
|
15
11
|
}
|
|
@@ -1,15 +1,12 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.matches = matches;
|
|
4
|
-
const index_js_1 = require("../../core/index.js");
|
|
1
|
+
import { validator, } from '../../core/index.js';
|
|
5
2
|
/**
|
|
6
3
|
* Coerces given value to "UUID" format or returns undefined if nullish
|
|
7
4
|
* @validator uuid
|
|
8
5
|
*/
|
|
9
|
-
function matches(format, options) {
|
|
6
|
+
export function matches(format, options) {
|
|
10
7
|
const regExp = format instanceof RegExp ? format : new RegExp(format);
|
|
11
8
|
const formatName = options?.formatName;
|
|
12
|
-
return
|
|
9
|
+
return validator('matches', (input, context, _this) => {
|
|
13
10
|
if (input == null)
|
|
14
11
|
return;
|
|
15
12
|
if (typeof input === 'string' && regExp.test(input))
|
package/esm/rules/index.js
CHANGED
|
@@ -1,53 +1,50 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
tslib_1.__exportStar(require("./utility-rules/pipe.js"), exports);
|
|
52
|
-
tslib_1.__exportStar(require("./utility-rules/required.js"), exports);
|
|
53
|
-
tslib_1.__exportStar(require("./utility-rules/union.js"), exports);
|
|
1
|
+
export * from './format-rules/is-alpha.js';
|
|
2
|
+
export * from './format-rules/is-ascii.js';
|
|
3
|
+
export * from './format-rules/is-base64.js';
|
|
4
|
+
export * from './format-rules/is-btc-address.js';
|
|
5
|
+
export * from './format-rules/is-credit-card.js';
|
|
6
|
+
export * from './format-rules/is-decimal.js';
|
|
7
|
+
export * from './format-rules/is-ean.js';
|
|
8
|
+
export * from './format-rules/is-email.js';
|
|
9
|
+
export * from './format-rules/is-eth-address.js';
|
|
10
|
+
export * from './format-rules/is-fqdn.js';
|
|
11
|
+
export * from './format-rules/is-hash.js';
|
|
12
|
+
export * from './format-rules/is-hex.js';
|
|
13
|
+
export * from './format-rules/is-hex-color.js';
|
|
14
|
+
export * from './format-rules/is-iban.js';
|
|
15
|
+
export * from './format-rules/is-ip.js';
|
|
16
|
+
export * from './format-rules/is-issn.js';
|
|
17
|
+
export * from './format-rules/is-jwt.js';
|
|
18
|
+
export * from './format-rules/is-lowercase.js';
|
|
19
|
+
export * from './format-rules/is-mac-address.js';
|
|
20
|
+
export * from './format-rules/is-mobile-phone.js';
|
|
21
|
+
export * from './format-rules/is-object-id.js';
|
|
22
|
+
export * from './format-rules/is-passport-number.js';
|
|
23
|
+
export * from './format-rules/is-port.js';
|
|
24
|
+
export * from './format-rules/is-url.js';
|
|
25
|
+
export * from './format-rules/is-uuid.js';
|
|
26
|
+
export * from './format-rules/is-vat-number.js';
|
|
27
|
+
export * from './format-rules/matches.js';
|
|
28
|
+
export * from './logical-rules/is-defined.js';
|
|
29
|
+
export * from './logical-rules/is-empty.js';
|
|
30
|
+
export * from './logical-rules/range.js';
|
|
31
|
+
export * from './type-rules/is-any.js';
|
|
32
|
+
export * from './type-rules/is-array.js';
|
|
33
|
+
export * from './type-rules/is-bigint.js';
|
|
34
|
+
export * from './type-rules/is-boolean.js';
|
|
35
|
+
export * from './type-rules/is-date.js';
|
|
36
|
+
export * from './type-rules/is-enum.js';
|
|
37
|
+
export * from './type-rules/is-integer.js';
|
|
38
|
+
export * from './type-rules/is-null.js';
|
|
39
|
+
export * from './type-rules/is-number.js';
|
|
40
|
+
export * from './type-rules/is-object.js';
|
|
41
|
+
export * from './type-rules/is-record.js';
|
|
42
|
+
export * from './type-rules/is-string.js';
|
|
43
|
+
export * from './type-rules/is-tuple.js';
|
|
44
|
+
export * from './type-rules/is-undefined.js';
|
|
45
|
+
export * from './utility-rules/exists.js';
|
|
46
|
+
export * from './utility-rules/get-length.js';
|
|
47
|
+
export * from './utility-rules/optional.js';
|
|
48
|
+
export * from './utility-rules/pipe.js';
|
|
49
|
+
export * from './utility-rules/required.js';
|
|
50
|
+
export * from './utility-rules/union.js';
|
|
@@ -1,13 +1,10 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.isDefined = isDefined;
|
|
4
|
-
const index_js_1 = require("../../core/index.js");
|
|
1
|
+
import { validator } from '../../core/index.js';
|
|
5
2
|
/**
|
|
6
3
|
* Validates if value is not "undefined" nor "null"
|
|
7
4
|
* @validator isDefined
|
|
8
5
|
*/
|
|
9
|
-
function isDefined(options) {
|
|
10
|
-
return
|
|
6
|
+
export function isDefined(options) {
|
|
7
|
+
return validator('is-defined', (input, context, _this) => {
|
|
11
8
|
if (input !== undefined)
|
|
12
9
|
return input;
|
|
13
10
|
context.fail(_this, `Is not defined`, input);
|
|
@@ -1,14 +1,10 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.isEmpty = isEmpty;
|
|
4
|
-
exports.isNotEmpty = isNotEmpty;
|
|
5
|
-
const index_js_1 = require("../../core/index.js");
|
|
1
|
+
import { validator } from '../../core/index.js';
|
|
6
2
|
/**
|
|
7
3
|
* Checks if value is an empty. Value should be string, array, set, map or object
|
|
8
4
|
* @validator isEmpty
|
|
9
5
|
*/
|
|
10
|
-
function isEmpty(options) {
|
|
11
|
-
return
|
|
6
|
+
export function isEmpty(options) {
|
|
7
|
+
return validator('isEmpty', (input, context, _this) => {
|
|
12
8
|
if (input == null)
|
|
13
9
|
return input;
|
|
14
10
|
if (typeof input === 'string') {
|
|
@@ -43,8 +39,8 @@ function isEmpty(options) {
|
|
|
43
39
|
* Checks if value is a not empty. Value should be string, array, set, map or object
|
|
44
40
|
* @validator isNotEmpty
|
|
45
41
|
*/
|
|
46
|
-
function isNotEmpty(options) {
|
|
47
|
-
return
|
|
42
|
+
export function isNotEmpty(options) {
|
|
43
|
+
return validator('isNotEmpty', (input, context, _this) => {
|
|
48
44
|
if (input != null) {
|
|
49
45
|
if (typeof input === 'string') {
|
|
50
46
|
if (input)
|