valgen 5.2.2 → 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 +16 -0
- package/cjs/core/context.js +7 -4
- package/cjs/core/validator.js +4 -4
- package/cjs/index.js +20 -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} +4 -4
- 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} +13 -3
- package/cjs/rules/logical-rules/range.js +114 -0
- package/cjs/rules/{is-any.js → type-rules/is-any.js} +1 -1
- package/cjs/rules/{is-array.js → type-rules/is-array.js} +5 -6
- package/cjs/rules/{is-bigint.js → type-rules/is-bigint.js} +5 -4
- package/cjs/rules/{is-boolean.js → type-rules/is-boolean.js} +5 -3
- package/cjs/rules/{is-date.js → type-rules/is-date.js} +12 -10
- package/cjs/rules/{is-enum.js → type-rules/is-enum.js} +6 -5
- package/cjs/rules/{is-integer.js → type-rules/is-integer.js} +5 -3
- package/cjs/rules/type-rules/is-null.js +34 -0
- package/cjs/rules/{is-number.js → type-rules/is-number.js} +6 -4
- package/cjs/rules/{is-object.js → type-rules/is-object.js} +5 -5
- package/cjs/rules/{is-record.js → type-rules/is-record.js} +1 -1
- package/cjs/rules/{is-string.js → type-rules/is-string.js} +3 -2
- package/cjs/rules/{is-tuple.js → type-rules/is-tuple.js} +5 -5
- 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} +3 -3
- package/esm/core/context.js +7 -4
- package/esm/core/validator.js +4 -4
- package/esm/index.js +10 -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} +4 -4
- 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} +13 -3
- 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} +5 -6
- package/esm/rules/{is-bigint.js → type-rules/is-bigint.js} +5 -4
- package/esm/rules/{is-boolean.js → type-rules/is-boolean.js} +5 -3
- package/esm/rules/{is-date.js → type-rules/is-date.js} +12 -10
- package/esm/rules/{is-enum.js → type-rules/is-enum.js} +6 -5
- package/esm/rules/{is-integer.js → type-rules/is-integer.js} +5 -3
- package/esm/rules/type-rules/is-null.js +29 -0
- package/esm/rules/{is-number.js → type-rules/is-number.js} +6 -4
- package/esm/rules/{is-object.js → type-rules/is-object.js} +5 -5
- package/esm/rules/{is-record.js → type-rules/is-record.js} +1 -1
- package/esm/rules/{is-string.js → type-rules/is-string.js} +3 -2
- package/esm/rules/{is-tuple.js → type-rules/is-tuple.js} +5 -5
- 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} +3 -3
- package/package.json +2 -2
- package/typings/core/types.d.ts +1 -0
- package/typings/index.d.ts +11 -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/is-null.js +0 -58
- package/cjs/rules/length.js +0 -41
- package/cjs/rules/optional.js +0 -44
- package/cjs/rules/range.js +0 -89
- package/cjs/rules/string-formats.js +0 -377
- package/esm/rules/is-null.js +0 -51
- 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
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import * as validatorJS from 'validator';
|
|
2
|
+
import { ValidationOptions } from '../../core/index.js';
|
|
3
|
+
export interface IsMobilePhoneOptions extends ValidationOptions {
|
|
4
|
+
/**
|
|
5
|
+
* If this is set to `true`, the mobile phone number must be supplied with the country code and therefore must start with `+`.
|
|
6
|
+
*
|
|
7
|
+
* @default false
|
|
8
|
+
*/
|
|
9
|
+
strictMode?: boolean;
|
|
10
|
+
/**
|
|
11
|
+
* Locale or locales of the mobile phone
|
|
12
|
+
* @default 'any'
|
|
13
|
+
*/
|
|
14
|
+
locale?: 'any' | validatorJS.MobilePhoneLocale | validatorJS.MobilePhoneLocale[];
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Validates if value is a valid Email
|
|
18
|
+
* @validator isMobilePhone
|
|
19
|
+
*/
|
|
20
|
+
export declare function isMobilePhone(options?: IsMobilePhoneOptions): import("../../core/validator.js").Validator<string, string, import("../../core/types.js").ExecutionOptions>;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ValidationOptions } from '
|
|
1
|
+
import { ValidationOptions } from '../../core/index.js';
|
|
2
2
|
export declare interface ObjectIdLike {
|
|
3
3
|
id: string | Uint8Array;
|
|
4
4
|
toHexString(): string;
|
|
@@ -7,4 +7,4 @@ export declare interface ObjectIdLike {
|
|
|
7
7
|
* Validates if value is an "ObjectId".
|
|
8
8
|
* @validator isObjectId
|
|
9
9
|
*/
|
|
10
|
-
export declare function isObjectId(options?: ValidationOptions): import("
|
|
10
|
+
export declare function isObjectId(options?: ValidationOptions): import("../../core/validator.js").Validator<string | ObjectIdLike | Uint8Array, unknown, import("../../core/types.js").ExecutionOptions>;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { ValidationOptions } from '../../core/index.js';
|
|
2
|
+
/**
|
|
3
|
+
* Validates if value is a passport number
|
|
4
|
+
* @validator isPassportNumber
|
|
5
|
+
*/
|
|
6
|
+
export declare function isPassportNumber(countryCode: string, options?: ValidationOptions): import("../../core/validator.js").Validator<string, string, import("../../core/types.js").ExecutionOptions>;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { ValidationOptions } from '../../core/index.js';
|
|
2
|
+
/**
|
|
3
|
+
* Validates if value is a port number
|
|
4
|
+
* @validator isPort
|
|
5
|
+
*/
|
|
6
|
+
export declare function isPort(options?: ValidationOptions): import("../../core/validator.js").Validator<string, string, import("../../core/types.js").ExecutionOptions>;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import * as validatorJS from 'validator';
|
|
2
|
+
import { ValidationOptions } from '../../core/index.js';
|
|
3
|
+
export interface IsURLOptions extends ValidationOptions, validatorJS.IsURLOptions {
|
|
4
|
+
}
|
|
5
|
+
/**
|
|
6
|
+
* Validates if value is an URL
|
|
7
|
+
* @validator isURL
|
|
8
|
+
*/
|
|
9
|
+
export declare function isURL(options?: IsURLOptions): import("../../core/validator.js").Validator<string, string, import("../../core/types.js").ExecutionOptions>;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { ValidationOptions } from '../../core/index.js';
|
|
2
|
+
/**
|
|
3
|
+
* Validates if value is an "UUID".
|
|
4
|
+
* @validator isUUID
|
|
5
|
+
*/
|
|
6
|
+
export declare function isUUID(version?: 1 | 2 | 3 | 4 | 5, options?: ValidationOptions): import("../../core/validator.js").Validator<string, string, import("../../core/types.js").ExecutionOptions>;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { ValidationOptions } from '../../core/index.js';
|
|
2
|
+
/**
|
|
3
|
+
* Validates if value is an VAT number
|
|
4
|
+
* @validator isVAT
|
|
5
|
+
*/
|
|
6
|
+
export declare function isVATNumber(countryCode: string, options?: ValidationOptions): import("../../core/validator.js").Validator<string, string, import("../../core/types.js").ExecutionOptions>;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { ValidationOptions } from '../../core/index.js';
|
|
2
|
+
export interface IsRegExpOptions extends ValidationOptions {
|
|
3
|
+
formatName?: string;
|
|
4
|
+
}
|
|
5
|
+
/**
|
|
6
|
+
* Coerces given value to "UUID" format or returns undefined if nullish
|
|
7
|
+
* @validator uuid
|
|
8
|
+
*/
|
|
9
|
+
export declare function matches(format: string | RegExp, options?: IsRegExpOptions): import("../../core/validator.js").Validator<string, string, import("../../core/types.js").ExecutionOptions>;
|
package/typings/rules/index.d.ts
CHANGED
|
@@ -1,22 +1,49 @@
|
|
|
1
|
-
export * from './is-any.js';
|
|
2
|
-
export * from './is-array.js';
|
|
3
|
-
export * from './is-bigint.js';
|
|
4
|
-
export * from './is-boolean.js';
|
|
5
|
-
export * from './is-date.js';
|
|
6
|
-
export * from './is-
|
|
7
|
-
export * from './is-
|
|
8
|
-
export * from './is-
|
|
9
|
-
export * from './is-
|
|
10
|
-
export * from './is-
|
|
11
|
-
export * from './is-
|
|
12
|
-
export * from './is-
|
|
13
|
-
export * from './is-
|
|
14
|
-
export * from './is-
|
|
15
|
-
export * from './is-
|
|
16
|
-
export * from './is-
|
|
17
|
-
export * from './
|
|
18
|
-
export * from './
|
|
19
|
-
export * from './
|
|
20
|
-
export * from './
|
|
21
|
-
export * from './
|
|
22
|
-
export * from './
|
|
1
|
+
export * from './type-rules/is-any.js';
|
|
2
|
+
export * from './type-rules/is-array.js';
|
|
3
|
+
export * from './type-rules/is-bigint.js';
|
|
4
|
+
export * from './type-rules/is-boolean.js';
|
|
5
|
+
export * from './type-rules/is-date.js';
|
|
6
|
+
export * from './type-rules/is-enum.js';
|
|
7
|
+
export * from './type-rules/is-integer.js';
|
|
8
|
+
export * from './type-rules/is-null.js';
|
|
9
|
+
export * from './type-rules/is-number.js';
|
|
10
|
+
export * from './type-rules/is-object.js';
|
|
11
|
+
export * from './type-rules/is-record.js';
|
|
12
|
+
export * from './type-rules/is-string.js';
|
|
13
|
+
export * from './type-rules/is-tuple.js';
|
|
14
|
+
export * from './format-rules/is-alpha.js';
|
|
15
|
+
export * from './format-rules/is-ascii.js';
|
|
16
|
+
export * from './format-rules/is-base64.js';
|
|
17
|
+
export * from './format-rules/is-btc-address.js';
|
|
18
|
+
export * from './format-rules/is-credit-card.js';
|
|
19
|
+
export * from './format-rules/is-decimal.js';
|
|
20
|
+
export * from './format-rules/is-ean.js';
|
|
21
|
+
export * from './format-rules/is-email.js';
|
|
22
|
+
export * from './format-rules/is-eth-address.js';
|
|
23
|
+
export * from './format-rules/is-fqdn.js';
|
|
24
|
+
export * from './format-rules/is-hash.js';
|
|
25
|
+
export * from './format-rules/is-hex.js';
|
|
26
|
+
export * from './format-rules/is-hex-color.js';
|
|
27
|
+
export * from './format-rules/is-iban.js';
|
|
28
|
+
export * from './format-rules/is-ip.js';
|
|
29
|
+
export * from './format-rules/is-issn.js';
|
|
30
|
+
export * from './format-rules/is-jwt.js';
|
|
31
|
+
export * from './format-rules/is-lowercase.js';
|
|
32
|
+
export * from './format-rules/is-mac-address.js';
|
|
33
|
+
export * from './format-rules/is-mobile-phone.js';
|
|
34
|
+
export * from './format-rules/is-object-id.js';
|
|
35
|
+
export * from './format-rules/is-passport-number.js';
|
|
36
|
+
export * from './format-rules/is-port.js';
|
|
37
|
+
export * from './format-rules/is-url.js';
|
|
38
|
+
export * from './format-rules/is-uuid.js';
|
|
39
|
+
export * from './format-rules/is-vat-number.js';
|
|
40
|
+
export * from './format-rules/matches.js';
|
|
41
|
+
export * from './logical-rules/is-defined.js';
|
|
42
|
+
export * from './logical-rules/is-empty.js';
|
|
43
|
+
export * from './logical-rules/range.js';
|
|
44
|
+
export * from './utility-rules/exists.js';
|
|
45
|
+
export * from './utility-rules/get-length.js';
|
|
46
|
+
export * from './utility-rules/optional.js';
|
|
47
|
+
export * from './utility-rules/pipe.js';
|
|
48
|
+
export * from './utility-rules/required.js';
|
|
49
|
+
export * from './utility-rules/union.js';
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { ValidationOptions } from '../../core/index.js';
|
|
2
|
+
/**
|
|
3
|
+
* Validates if value is not "undefined" nor "null"
|
|
4
|
+
* @validator isDefined
|
|
5
|
+
*/
|
|
6
|
+
export declare function isDefined(options?: ValidationOptions): import("../../core/validator.js").Validator<any, unknown, import("../../core/types.js").ExecutionOptions>;
|
|
7
|
+
/**
|
|
8
|
+
* Validates if value is "undefined"
|
|
9
|
+
* @validator isUndefined
|
|
10
|
+
*/
|
|
11
|
+
export declare function isUndefined(options?: ValidationOptions): import("../../core/validator.js").Validator<any, unknown, import("../../core/types.js").ExecutionOptions>;
|
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import { ValidationOptions } from '
|
|
1
|
+
import { ValidationOptions } from '../../core/index.js';
|
|
2
2
|
type IsEmptyInput = string | any[] | object | Set<any> | Map<any, any>;
|
|
3
3
|
/**
|
|
4
4
|
* Checks if value is an empty. Value should be string, array, set, map or object
|
|
5
5
|
* @validator isEmpty
|
|
6
6
|
*/
|
|
7
|
-
export declare function isEmpty(options?: ValidationOptions): import("
|
|
7
|
+
export declare function isEmpty(options?: ValidationOptions): import("../../core/validator.js").Validator<IsEmptyInput, IsEmptyInput, import("../../core/types.js").ExecutionOptions>;
|
|
8
8
|
/**
|
|
9
9
|
* Checks if value is a not empty. Value should be string, array, set, map or object
|
|
10
10
|
* @validator isNotEmpty
|
|
11
11
|
*/
|
|
12
|
-
export declare function isNotEmpty(options?: ValidationOptions): import("
|
|
12
|
+
export declare function isNotEmpty(options?: ValidationOptions): import("../../core/validator.js").Validator<IsEmptyInput, IsEmptyInput, import("../../core/types.js").ExecutionOptions>;
|
|
13
13
|
export {};
|
|
@@ -1,5 +1,10 @@
|
|
|
1
|
-
import { ValidationOptions, Validator } from '
|
|
1
|
+
import { ValidationOptions, Validator } from '../../core/index.js';
|
|
2
2
|
type RangeInput = number | bigint | Date | string;
|
|
3
|
+
/**
|
|
4
|
+
* Checks if value is between minValue and maxValue
|
|
5
|
+
* @validator range
|
|
6
|
+
*/
|
|
7
|
+
export declare function range<T extends RangeInput>(minValue: T, maxValue: T, options?: ValidationOptions): Validator<T, T, import("../../core/types.js").ExecutionOptions>;
|
|
3
8
|
/**
|
|
4
9
|
* Checks if value is grater than "minValue"
|
|
5
10
|
* @validator iGt
|
|
@@ -41,8 +46,13 @@ export declare function isLte(maxValue: string, options?: ValidationOptions & {
|
|
|
41
46
|
caseInsensitive?: boolean;
|
|
42
47
|
}): Validator<string, string>;
|
|
43
48
|
/**
|
|
44
|
-
* Checks
|
|
45
|
-
* @validator
|
|
49
|
+
* Checks the length is at least "minValue"
|
|
50
|
+
* @validator lengthMin
|
|
51
|
+
*/
|
|
52
|
+
export declare const lengthMin: (minValue: number) => Validator<any, any, import("../../core/types.js").ExecutionOptions>;
|
|
53
|
+
/**
|
|
54
|
+
* Checks if the length is at most "maxValue"
|
|
55
|
+
* @validator lengthMax
|
|
46
56
|
*/
|
|
47
|
-
export declare
|
|
57
|
+
export declare const lengthMax: (maxValue: number) => Validator<any, any, import("../../core/types.js").ExecutionOptions>;
|
|
48
58
|
export {};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { ValidationOptions, Validator } from '
|
|
1
|
+
import { ValidationOptions, Validator } from '../../core/index.js';
|
|
2
2
|
/**
|
|
3
3
|
* Validates if value is "array" and applies validation for each item.
|
|
4
4
|
* Converts input value to array if coerce option is set to 'true'.
|
|
5
5
|
* @validator isArray
|
|
6
6
|
*/
|
|
7
|
-
export declare function isArray<T, I>(itemValidator?: Validator<T, I>, options?: ValidationOptions): Validator<T[], I | I[], import("
|
|
7
|
+
export declare function isArray<T, I>(itemValidator?: Validator<T, I>, options?: ValidationOptions): Validator<T[], I | I[], import("../../core/types.js").ExecutionOptions>;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { ValidationOptions } from '
|
|
1
|
+
import { ValidationOptions } from '../../core/index.js';
|
|
2
2
|
/**
|
|
3
3
|
* Validates if value is "BigInt".
|
|
4
4
|
* Converts input value to number if coerce option is set to 'true'.
|
|
5
5
|
* @validator isNumber
|
|
6
6
|
*/
|
|
7
|
-
export declare function isBigint(options?: ValidationOptions): import("
|
|
7
|
+
export declare function isBigint(options?: ValidationOptions): import("../../core/validator.js").Validator<bigint, unknown, import("../../core/types.js").ExecutionOptions>;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { ValidationOptions } from '
|
|
1
|
+
import { ValidationOptions } from '../../core/index.js';
|
|
2
2
|
/**
|
|
3
3
|
* Validates if value is "boolean".
|
|
4
4
|
* Converts input value to boolean if coerce option is set to 'true'.
|
|
5
5
|
* @validator isBoolean
|
|
6
6
|
*/
|
|
7
|
-
export declare function isBoolean(options?: ValidationOptions): import("
|
|
7
|
+
export declare function isBoolean(options?: ValidationOptions): import("../../core/validator.js").Validator<boolean | undefined, unknown, import("../../core/types.js").ExecutionOptions>;
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { ValidationOptions } from '
|
|
1
|
+
import { ValidationOptions } from '../../core/index.js';
|
|
2
2
|
/**
|
|
3
3
|
* Validates if value is instance of "Date".
|
|
4
4
|
* Converts input value to Date if coerce option is set to 'true'.
|
|
5
5
|
* @validator isDate
|
|
6
6
|
*/
|
|
7
|
-
export declare function isDate(options?: isDate.Options): import("
|
|
7
|
+
export declare function isDate(options?: isDate.Options): import("../../core/validator.js").Validator<Date, string | number | Date, import("../../core/types.js").ExecutionOptions>;
|
|
8
8
|
export interface IsDateStringOptions extends ValidationOptions {
|
|
9
9
|
precision?: 'year' | 'month' | 'date' | 'time';
|
|
10
10
|
trim?: 'date' | 'time';
|
|
@@ -14,7 +14,7 @@ export interface IsDateStringOptions extends ValidationOptions {
|
|
|
14
14
|
* Converts input value to DFS if coerce option is set to 'true'.
|
|
15
15
|
* @validator isDateString
|
|
16
16
|
*/
|
|
17
|
-
export declare function isDateString(options?: IsDateStringOptions): import("
|
|
17
|
+
export declare function isDateString(options?: IsDateStringOptions): import("../../core/validator.js").Validator<string, string | number | Date, import("../../core/types.js").ExecutionOptions>;
|
|
18
18
|
export declare namespace isDate {
|
|
19
19
|
interface Options extends ValidationOptions {
|
|
20
20
|
precision?: 'year' | 'month' | 'date' | 'time';
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { ValidationOptions } from '
|
|
1
|
+
import { ValidationOptions } from '../../core/index.js';
|
|
2
2
|
/**
|
|
3
3
|
* Validates if value is "integer".
|
|
4
4
|
* Converts input value to integer number if coerce option is set to 'true'.
|
|
5
5
|
* @validator isInteger
|
|
6
6
|
*/
|
|
7
|
-
export declare function isInteger(options?: ValidationOptions): import("
|
|
7
|
+
export declare function isInteger(options?: ValidationOptions): import("../../core/validator.js").Validator<number, unknown, import("../../core/types.js").ExecutionOptions>;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { ValidationOptions } from '../../core/index.js';
|
|
2
|
+
/**
|
|
3
|
+
* Validates if value is "null".
|
|
4
|
+
* @validator isNull
|
|
5
|
+
*/
|
|
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 "null" or "undefined".
|
|
9
|
+
* @validator isNull
|
|
10
|
+
*/
|
|
11
|
+
export declare function isNullish(options?: ValidationOptions): import("../../core/validator.js").Validator<null, unknown, import("../../core/types.js").ExecutionOptions>;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { ValidationOptions } from '
|
|
1
|
+
import { ValidationOptions } from '../../core/index.js';
|
|
2
2
|
/**
|
|
3
3
|
* Validates if value is "number".
|
|
4
4
|
* Converts input value to number if coerce option is set to 'true'.
|
|
5
5
|
* @validator isNumber
|
|
6
6
|
*/
|
|
7
|
-
export declare function isNumber(options?: ValidationOptions): import("
|
|
7
|
+
export declare function isNumber(options?: ValidationOptions): import("../../core/validator.js").Validator<number, unknown, import("../../core/types.js").ExecutionOptions>;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Type, ValidationOptions, Validator as Validator_ } from '
|
|
1
|
+
import { Type, ValidationOptions, Validator as Validator_ } from '../../core/index.js';
|
|
2
2
|
export declare namespace IsObject {
|
|
3
3
|
interface Validator<T extends object = object, I = object> extends Validator_<T, I> {
|
|
4
4
|
schema: Schema;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { ValidationOptions, Validator } from '
|
|
1
|
+
import { ValidationOptions, Validator } from '../../core/index.js';
|
|
2
2
|
/**
|
|
3
3
|
* Validates record object according to given "key" and "value" rules
|
|
4
4
|
* Converts properties according to rules if coerce option is set to 'true'.
|
|
5
5
|
* @validator isRecord
|
|
6
6
|
*/
|
|
7
|
-
export declare function isRecord<TKeys extends string | number | symbol, TValues>(keyRule: Validator<TKeys>, valueRule: Validator<TValues>, options?: ValidationOptions): Validator<Record<TKeys, TValues>, Record<TKeys, TValues>, import("
|
|
7
|
+
export declare function isRecord<TKeys extends string | number | symbol, TValues>(keyRule: Validator<TKeys>, valueRule: Validator<TValues>, options?: ValidationOptions): Validator<Record<TKeys, TValues>, Record<TKeys, TValues>, import("../../core/types.js").ExecutionOptions>;
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { ValidationOptions } from '
|
|
1
|
+
import { ValidationOptions } from '../../core/index.js';
|
|
2
2
|
/**
|
|
3
3
|
* Validates if value is "string".
|
|
4
4
|
* Converts input value to string if coerce option is set to 'true'.
|
|
5
5
|
* @validator isString
|
|
6
6
|
*/
|
|
7
|
-
export declare function isString(options?: ValidationOptions): import("
|
|
7
|
+
export declare function isString(options?: ValidationOptions): import("../../core/validator.js").Validator<string, unknown, import("../../core/types.js").ExecutionOptions>;
|
|
8
8
|
/**
|
|
9
9
|
* Process "String.replace" method
|
|
10
10
|
* @validator stringReplace
|
|
@@ -29,14 +29,14 @@ export declare function stringSplit(splitter: {
|
|
|
29
29
|
* Removes whitespace from both ends of a string
|
|
30
30
|
* @validator trim
|
|
31
31
|
*/
|
|
32
|
-
export declare function trim(): import("
|
|
32
|
+
export declare function trim(): import("../../core/validator.js").Validator<string, string, import("../../core/types.js").ExecutionOptions>;
|
|
33
33
|
/**
|
|
34
34
|
* Removes whitespace from the end of a string
|
|
35
35
|
* @validator trimEnd
|
|
36
36
|
*/
|
|
37
|
-
export declare const trimEnd: () => import("
|
|
37
|
+
export declare const trimEnd: () => import("../../core/validator.js").Validator<string, string, import("../../core/types.js").ExecutionOptions>;
|
|
38
38
|
/**
|
|
39
39
|
* Removes whitespace from the beginning of a string
|
|
40
40
|
* @validator trimStart
|
|
41
41
|
*/
|
|
42
|
-
export declare const trimStart: () => import("
|
|
42
|
+
export declare const trimStart: () => import("../../core/validator.js").Validator<string, string, import("../../core/types.js").ExecutionOptions>;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ValidationOptions, Validator } from '
|
|
1
|
+
import { ValidationOptions, Validator } from '../../core/index.js';
|
|
2
2
|
/**
|
|
3
3
|
* Validates if value is "tuple" and applies validation for each item.
|
|
4
4
|
* Converts input value to tuple if coerce option is set to 'true'.
|
|
@@ -9,13 +9,7 @@ export declare function isTuple<T1, I1, T2, I2>(items: [Validator<T1, I1>, Valid
|
|
|
9
9
|
export declare function isTuple<T1, I1, T2, I2, T3, I3>(items: [Validator<T1, I1>, Validator<T2, I2>, Validator<T3, I3>], options?: ValidationOptions): Validator<[T1, T2, T3], [I1, I2, I3]>;
|
|
10
10
|
export declare function isTuple<T1, I1, T2, I2, T3, I3, T4, I4>(items: [Validator<T1, I1>, Validator<T2, I2>, Validator<T3, I3>, Validator<T4, I4>], options?: ValidationOptions): Validator<[T1, T2, T3, T4], [I1, I2, I3, I4]>;
|
|
11
11
|
export declare function isTuple<T1, I1, T2, I2, T3, I3, T4, I4>(items: [Validator<T1, I1>, Validator<T2, I2>, Validator<T3, I3>, Validator<T4, I4>], options?: ValidationOptions): Validator<[T1, T2, T3, T4], [I1, I2, I3, I4]>;
|
|
12
|
-
export declare function isTuple<T1, I1, T2, I2, T3, I3, T4, I4, T5, I5>(items: [
|
|
13
|
-
Validator<T1, I1>,
|
|
14
|
-
Validator<T2, I2>,
|
|
15
|
-
Validator<T3, I3>,
|
|
16
|
-
Validator<T4, I4>,
|
|
17
|
-
Validator<T5, I5>
|
|
18
|
-
], options?: ValidationOptions): Validator<[T1, T2, T3, T4, T5], [I1, I2, I3, I4, I5]>;
|
|
12
|
+
export declare function isTuple<T1, I1, T2, I2, T3, I3, T4, I4, T5, I5>(items: [Validator<T1, I1>, Validator<T2, I2>, Validator<T3, I3>, Validator<T4, I4>, Validator<T5, I5>], options?: ValidationOptions): Validator<[T1, T2, T3, T4, T5], [I1, I2, I3, I4, I5]>;
|
|
19
13
|
export declare function isTuple<T1, I1, T2, I2, T3, I3, T4, I4, T5, I5, T6, I6>(items: [
|
|
20
14
|
Validator<T1, I1>,
|
|
21
15
|
Validator<T2, I2>,
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { ValidationOptions } from '../../core/index.js';
|
|
2
|
+
/**
|
|
3
|
+
* Validates if property exists
|
|
4
|
+
* @validator exists
|
|
5
|
+
*/
|
|
6
|
+
export declare function exists(options?: ValidationOptions): import("../../core/validator.js").Validator<any, unknown, import("../../core/types.js").ExecutionOptions>;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
type ExtractLengthInput = string | any[] | ArrayBuffer | {
|
|
2
|
+
length: number;
|
|
3
|
+
} | {
|
|
4
|
+
size: number;
|
|
5
|
+
};
|
|
6
|
+
/**
|
|
7
|
+
* Returns length of an Array, String, ArrayBuffer, Buffer or any object with the "length" property.
|
|
8
|
+
* @validator getLength
|
|
9
|
+
*/
|
|
10
|
+
export declare function getLength(): import("../../core/validator.js").Validator<number, ExtractLengthInput, import("../../core/types.js").ExecutionOptions>;
|
|
11
|
+
export {};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { Nullish } from 'ts-gems';
|
|
2
|
+
import { ValidationOptions, Validator } from '../../core/index.js';
|
|
3
|
+
/**
|
|
4
|
+
* Makes sub-rule optional
|
|
5
|
+
* @validator optional
|
|
6
|
+
*/
|
|
7
|
+
export declare function optional<T, I>(nested: Validator<T, I>, options?: ValidationOptions): Validator<Nullish<T>, Nullish<I>, import("../../core/types.js").ExecutionOptions>;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { Nullish } from 'ts-gems';
|
|
2
|
+
import { ValidationOptions, Validator } from '../../core/index.js';
|
|
3
|
+
/**
|
|
4
|
+
* Makes sub-rule required
|
|
5
|
+
* @validator required
|
|
6
|
+
*/
|
|
7
|
+
export declare function required<T, I>(nested: Validator<T, I>, options?: ValidationOptions): Validator<Nullish<T>, I, import("../../core/types.js").ExecutionOptions>;
|
package/cjs/rules/is-null.js
DELETED
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.isUndefined = exports.isDefined = exports.isNullish = exports.isNull = void 0;
|
|
4
|
-
const index_js_1 = require("../core/index.js");
|
|
5
|
-
/**
|
|
6
|
-
* Validates if value is "null".
|
|
7
|
-
* @validator isNull
|
|
8
|
-
*/
|
|
9
|
-
function isNull(options) {
|
|
10
|
-
return (0, index_js_1.validator)('isNull', function (input, context, _this) {
|
|
11
|
-
if (input === null)
|
|
12
|
-
return input;
|
|
13
|
-
if (context.coerce)
|
|
14
|
-
return null;
|
|
15
|
-
context.fail(_this, `{{label}} must be null`, input);
|
|
16
|
-
}, options);
|
|
17
|
-
}
|
|
18
|
-
exports.isNull = isNull;
|
|
19
|
-
/**
|
|
20
|
-
* Validates if value is "null" or "undefined".
|
|
21
|
-
* @validator isNull
|
|
22
|
-
*/
|
|
23
|
-
function isNullish(options) {
|
|
24
|
-
return (0, index_js_1.validator)('isNullish', function (input, context, _this) {
|
|
25
|
-
if (input == null)
|
|
26
|
-
return input;
|
|
27
|
-
if (context.coerce)
|
|
28
|
-
return null;
|
|
29
|
-
context.fail(_this, `{{label}} must be null or undefined`, input);
|
|
30
|
-
}, options);
|
|
31
|
-
}
|
|
32
|
-
exports.isNullish = isNullish;
|
|
33
|
-
/**
|
|
34
|
-
* Validates if value is not "undefined" nor "null"
|
|
35
|
-
* @validator isDefined
|
|
36
|
-
*/
|
|
37
|
-
function isDefined(options) {
|
|
38
|
-
return (0, index_js_1.validator)('is-defined', function (input, context, _this) {
|
|
39
|
-
if (input !== undefined)
|
|
40
|
-
return input;
|
|
41
|
-
context.fail(_this, `{{label}} must be defined`, input);
|
|
42
|
-
}, options);
|
|
43
|
-
}
|
|
44
|
-
exports.isDefined = isDefined;
|
|
45
|
-
/**
|
|
46
|
-
* Validates if value is "undefined"
|
|
47
|
-
* @validator isUndefined
|
|
48
|
-
*/
|
|
49
|
-
function isUndefined(options) {
|
|
50
|
-
return (0, index_js_1.validator)('isUndefined', function (input, context, _this) {
|
|
51
|
-
if (context.coerce)
|
|
52
|
-
return undefined;
|
|
53
|
-
if (input === undefined)
|
|
54
|
-
return;
|
|
55
|
-
context.fail(_this, `{{label}} mustn\'t be defined`, input);
|
|
56
|
-
}, options);
|
|
57
|
-
}
|
|
58
|
-
exports.isUndefined = isUndefined;
|
package/cjs/rules/length.js
DELETED
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.lengthMax = exports.lengthMin = exports.extractLength = void 0;
|
|
4
|
-
const index_js_1 = require("../core/index.js");
|
|
5
|
-
const pipe_js_1 = require("./pipe.js");
|
|
6
|
-
const range_js_1 = require("./range.js");
|
|
7
|
-
/**
|
|
8
|
-
* Returns length of an Array, String, ArrayBuffer, Buffer or any object with the "length" property.
|
|
9
|
-
* @validator getLength
|
|
10
|
-
*/
|
|
11
|
-
const extractLength = () => extractLengthRule;
|
|
12
|
-
exports.extractLength = extractLength;
|
|
13
|
-
const extractLengthRule = (0, index_js_1.validator)('extractLength', function (input, context, _this) {
|
|
14
|
-
if (typeof input === 'string')
|
|
15
|
-
return input.length;
|
|
16
|
-
if (Array.isArray(input))
|
|
17
|
-
return input.length;
|
|
18
|
-
if (input instanceof ArrayBuffer)
|
|
19
|
-
return input.byteLength;
|
|
20
|
-
if (input && typeof input === 'object' && typeof input.length === 'number')
|
|
21
|
-
return input.length;
|
|
22
|
-
if (input && typeof input === 'object' && typeof input.size === 'number')
|
|
23
|
-
return input.size;
|
|
24
|
-
context.fail(_this, `Unable to extract length of {{label}}`, input);
|
|
25
|
-
});
|
|
26
|
-
/**
|
|
27
|
-
* Checks the length is at least "minValue"
|
|
28
|
-
* @validator lengthMin
|
|
29
|
-
*/
|
|
30
|
-
const lengthMin = (minValue) => (0, pipe_js_1.allOf)((0, pipe_js_1.pipe)((0, exports.extractLength)(), (0, range_js_1.isGte)(minValue, {
|
|
31
|
-
onFail: () => `The length of {{label}} must be at least ${minValue}`
|
|
32
|
-
})));
|
|
33
|
-
exports.lengthMin = lengthMin;
|
|
34
|
-
/**
|
|
35
|
-
* Checks if the length is at most "maxValue"
|
|
36
|
-
* @validator charLengthMax
|
|
37
|
-
*/
|
|
38
|
-
const lengthMax = (maxValue) => (0, pipe_js_1.allOf)((0, pipe_js_1.pipe)((0, exports.extractLength)(), (0, range_js_1.isLte)(maxValue, {
|
|
39
|
-
onFail: () => `The length of {{label}} must be at most ${maxValue}`
|
|
40
|
-
})));
|
|
41
|
-
exports.lengthMax = lengthMax;
|
package/cjs/rules/optional.js
DELETED
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.exists = exports.required = exports.optional = void 0;
|
|
4
|
-
const index_js_1 = require("../core/index.js");
|
|
5
|
-
/**
|
|
6
|
-
* Makes sub-rule optional
|
|
7
|
-
* @validator optional
|
|
8
|
-
*/
|
|
9
|
-
function optional(nested, options) {
|
|
10
|
-
return (0, index_js_1.validator)('optional', function (input, context) {
|
|
11
|
-
if (input == null)
|
|
12
|
-
return input;
|
|
13
|
-
return nested(input, context);
|
|
14
|
-
}, options);
|
|
15
|
-
}
|
|
16
|
-
exports.optional = optional;
|
|
17
|
-
/**
|
|
18
|
-
* Makes sub-rule required
|
|
19
|
-
* @validator required
|
|
20
|
-
*/
|
|
21
|
-
function required(nested, options) {
|
|
22
|
-
return (0, index_js_1.validator)('required', function (input, context, _this) {
|
|
23
|
-
if (input == null) {
|
|
24
|
-
context.fail(_this, `{{label}} is required`, input);
|
|
25
|
-
return;
|
|
26
|
-
}
|
|
27
|
-
return nested(input, context);
|
|
28
|
-
}, options);
|
|
29
|
-
}
|
|
30
|
-
exports.required = required;
|
|
31
|
-
/**
|
|
32
|
-
* Validates if property exists
|
|
33
|
-
* @validator exists
|
|
34
|
-
*/
|
|
35
|
-
function exists(options) {
|
|
36
|
-
return (0, index_js_1.validator)('exists', function (input, context, _this) {
|
|
37
|
-
if (input !== undefined ||
|
|
38
|
-
(context.scope &&
|
|
39
|
-
Object.getOwnPropertyDescriptor(context.scope, input)))
|
|
40
|
-
return input;
|
|
41
|
-
context.fail(_this, `{{label}} must exist`, input);
|
|
42
|
-
}, options);
|
|
43
|
-
}
|
|
44
|
-
exports.exists = exists;
|