valgen 5.19.5 → 6.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/constants.js +1 -1
- package/index.d.ts +7 -7
- package/index.js +8 -5
- package/package.json +3 -3
- package/rules/format-rules/is-alpha.d.ts +5 -6
- package/rules/format-rules/is-alpha.js +1 -13
- package/rules/format-rules/is-alphanumeric.d.ts +10 -0
- package/rules/format-rules/is-alphanumeric.js +14 -0
- package/rules/format-rules/is-ascii.d.ts +5 -1
- package/rules/format-rules/is-base64.d.ts +6 -4
- package/rules/format-rules/is-btc-address.d.ts +5 -1
- package/rules/format-rules/is-credit-card.d.ts +6 -4
- package/rules/format-rules/is-decimal.d.ts +5 -1
- package/rules/format-rules/is-ean.d.ts +5 -1
- package/rules/format-rules/is-email.d.ts +59 -57
- package/rules/format-rules/is-eth-address.d.ts +6 -2
- package/rules/format-rules/is-eth-address.js +1 -1
- package/rules/format-rules/is-fqdn.d.ts +10 -8
- package/rules/format-rules/is-hash.d.ts +5 -3
- package/rules/format-rules/is-hex-color.d.ts +5 -1
- package/rules/format-rules/is-hex.d.ts +5 -1
- package/rules/format-rules/is-iban.d.ts +5 -6
- package/rules/format-rules/is-iban.js +0 -11
- package/rules/format-rules/is-ip.d.ts +9 -2
- package/rules/format-rules/is-issn.d.ts +11 -9
- package/rules/format-rules/is-jwt.d.ts +5 -1
- package/rules/format-rules/is-lowercase.d.ts +5 -6
- package/rules/format-rules/is-lowercase.js +0 -12
- package/rules/format-rules/is-mac-address.d.ts +18 -16
- package/rules/format-rules/is-mobile-phone.d.ts +17 -15
- package/rules/format-rules/is-object-id.d.ts +7 -5
- package/rules/format-rules/is-passport-number.d.ts +5 -1
- package/rules/format-rules/is-port.d.ts +5 -1
- package/rules/format-rules/is-swift.d.ts +10 -0
- package/rules/format-rules/is-swift.js +13 -0
- package/rules/format-rules/is-time.d.ts +5 -3
- package/rules/format-rules/is-uppercase.d.ts +10 -0
- package/rules/format-rules/is-uppercase.js +14 -0
- package/rules/format-rules/is-url.d.ts +6 -4
- package/rules/format-rules/is-uuid.d.ts +8 -2
- package/rules/format-rules/is-uuid.js +1 -1
- package/rules/format-rules/is-vat-number.d.ts +8 -2
- package/rules/format-rules/is-vat-number.js +1 -1
- package/rules/format-rules/matches.d.ts +6 -4
- package/rules/index.d.ts +9 -0
- package/rules/index.js +9 -0
- package/rules/logical-rules/is-defined.d.ts +5 -1
- package/rules/logical-rules/is-empty.d.ts +12 -4
- package/rules/logical-rules/is-empty.js +2 -2
- package/rules/logical-rules/is-equal.d.ts +10 -2
- package/rules/logical-rules/is-gt.d.ts +12 -0
- package/rules/logical-rules/is-gt.js +27 -0
- package/rules/logical-rules/is-gte.d.ts +12 -0
- package/rules/logical-rules/is-gte.js +27 -0
- package/rules/logical-rules/is-lt.d.ts +12 -0
- package/rules/logical-rules/is-lt.js +27 -0
- package/rules/logical-rules/is-lte.d.ts +12 -0
- package/rules/logical-rules/is-lte.js +27 -0
- package/rules/logical-rules/length.d.ts +10 -0
- package/rules/logical-rules/length.js +29 -0
- package/rules/logical-rules/range.d.ts +6 -42
- package/rules/logical-rules/range.js +0 -134
- package/rules/type-rules/is-any.d.ts +1 -1
- package/rules/type-rules/is-any.js +1 -1
- package/rules/type-rules/is-array.d.ts +7 -3
- package/rules/type-rules/is-array.js +2 -2
- package/rules/type-rules/is-bigint.d.ts +6 -2
- package/rules/type-rules/is-bigint.js +1 -1
- package/rules/type-rules/is-boolean.d.ts +6 -2
- package/rules/type-rules/is-boolean.js +1 -1
- package/rules/type-rules/is-date.d.ts +17 -12
- package/rules/type-rules/is-date.js +2 -2
- package/rules/type-rules/is-enum.d.ts +8 -5
- package/rules/type-rules/is-enum.js +1 -1
- package/rules/type-rules/is-integer.d.ts +7 -3
- package/rules/type-rules/is-integer.js +2 -2
- package/rules/type-rules/is-null.d.ts +24 -8
- package/rules/type-rules/is-null.js +4 -4
- package/rules/type-rules/is-number.d.ts +7 -3
- package/rules/type-rules/is-number.js +2 -2
- package/rules/type-rules/is-object.d.ts +7 -7
- package/rules/type-rules/is-object.js +3 -3
- package/rules/type-rules/is-record.d.ts +7 -3
- package/rules/type-rules/is-record.js +2 -2
- package/rules/type-rules/is-string.d.ts +7 -38
- package/rules/type-rules/is-string.js +2 -49
- package/rules/type-rules/is-tuple.d.ts +13 -9
- package/rules/type-rules/is-undefined.d.ts +6 -2
- package/rules/type-rules/is-undefined.js +1 -1
- package/rules/utility-rules/all-of.d.ts +6 -2
- package/rules/utility-rules/all-of.js +3 -3
- package/rules/utility-rules/exists.d.ts +5 -1
- package/rules/utility-rules/one-of.d.ts +6 -2
- package/rules/utility-rules/one-of.js +4 -4
- package/rules/utility-rules/optional.d.ts +6 -2
- package/rules/utility-rules/optional.js +1 -1
- package/rules/utility-rules/pipe.d.ts +6 -4
- package/rules/utility-rules/string-utils.d.ts +35 -0
- package/rules/utility-rules/string-utils.js +48 -0
|
@@ -1,20 +1,22 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { type MobilePhoneLocale as _MobilePhoneLocale } from '@browsery/validator';
|
|
2
2
|
import { type 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
3
|
/**
|
|
17
4
|
* Validates if value is a valid Email
|
|
18
5
|
* @validator isMobilePhone
|
|
19
6
|
*/
|
|
20
|
-
export declare function isMobilePhone(options?:
|
|
7
|
+
export declare function isMobilePhone(options?: isMobilePhone.Options): import("../../core/validator.js").Validator<string, string, import("../../core/types.js").ExecutionOptions>;
|
|
8
|
+
export declare namespace isMobilePhone {
|
|
9
|
+
interface Options extends ValidationOptions {
|
|
10
|
+
/**
|
|
11
|
+
* If this is set to `true`, the mobile phone number must be supplied with the country code and therefore must start with `+`.
|
|
12
|
+
*
|
|
13
|
+
* @default false
|
|
14
|
+
*/
|
|
15
|
+
strictMode?: boolean;
|
|
16
|
+
/**
|
|
17
|
+
* Locale or locales of the mobile phone
|
|
18
|
+
* @default 'any'
|
|
19
|
+
*/
|
|
20
|
+
locale?: 'any' | _MobilePhoneLocale | _MobilePhoneLocale[];
|
|
21
|
+
}
|
|
22
|
+
}
|
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
import { type ValidationOptions } from '../../core/index.js';
|
|
2
|
-
export declare interface ObjectIdLike {
|
|
3
|
-
id: string | Uint8Array;
|
|
4
|
-
toHexString(): string;
|
|
5
|
-
}
|
|
6
2
|
/**
|
|
7
3
|
* Validates if value is an "ObjectId".
|
|
8
4
|
* @validator isObjectId
|
|
9
5
|
*/
|
|
10
|
-
export declare function isObjectId(options?: ValidationOptions): import("../../core/validator.js").Validator<string |
|
|
6
|
+
export declare function isObjectId(options?: ValidationOptions): import("../../core/validator.js").Validator<string | Uint8Array<ArrayBufferLike> | isObjectId.ObjectIdLike, unknown, import("../../core/types.js").ExecutionOptions>;
|
|
7
|
+
export declare namespace isObjectId {
|
|
8
|
+
interface ObjectIdLike {
|
|
9
|
+
id: string | Uint8Array;
|
|
10
|
+
toHexString(): string;
|
|
11
|
+
}
|
|
12
|
+
}
|
|
@@ -3,4 +3,8 @@ import { type ValidationOptions } from '../../core/index.js';
|
|
|
3
3
|
* Validates if value is a passport number
|
|
4
4
|
* @validator isPassportNumber
|
|
5
5
|
*/
|
|
6
|
-
export declare function isPassportNumber(countryCode: string, options?:
|
|
6
|
+
export declare function isPassportNumber(countryCode: string, options?: isPassportNumber.Options): import("../../core/validator.js").Validator<string, string, import("../../core/types.js").ExecutionOptions>;
|
|
7
|
+
export declare namespace isPassportNumber {
|
|
8
|
+
interface Options extends ValidationOptions {
|
|
9
|
+
}
|
|
10
|
+
}
|
|
@@ -3,4 +3,8 @@ import { type ValidationOptions } from '../../core/index.js';
|
|
|
3
3
|
* Validates if value is a port number
|
|
4
4
|
* @validator isPort
|
|
5
5
|
*/
|
|
6
|
-
export declare function isPort(options?:
|
|
6
|
+
export declare function isPort(options?: isPort.Options): import("../../core/validator.js").Validator<number, string | number, import("../../core/types.js").ExecutionOptions>;
|
|
7
|
+
export declare namespace isPort {
|
|
8
|
+
interface Options extends ValidationOptions {
|
|
9
|
+
}
|
|
10
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { type ValidationOptions } from '../../core/index.js';
|
|
2
|
+
/**
|
|
3
|
+
* Validates if value is a BIC (Bank Identification Code) or SWIFT code
|
|
4
|
+
* @validator isSWIFT
|
|
5
|
+
*/
|
|
6
|
+
export declare function isSWIFT(options?: isSWIFT.Options): import("../../core/validator.js").Validator<string, string, import("../../core/types.js").ExecutionOptions>;
|
|
7
|
+
export declare namespace isSWIFT {
|
|
8
|
+
interface Options extends ValidationOptions {
|
|
9
|
+
}
|
|
10
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import validatorJS from '@browsery/validator';
|
|
2
|
+
import { validator, } from '../../core/index.js';
|
|
3
|
+
/**
|
|
4
|
+
* Validates if value is a BIC (Bank Identification Code) or SWIFT code
|
|
5
|
+
* @validator isSWIFT
|
|
6
|
+
*/
|
|
7
|
+
export function isSWIFT(options) {
|
|
8
|
+
return validator('isSWIFT', (input, context, _this) => {
|
|
9
|
+
if (typeof input === 'string' && validatorJS.isBIC(input))
|
|
10
|
+
return input;
|
|
11
|
+
context.fail(_this, `Value must be a valid a BIC (Bank Identification Code) or SWIFT code`, input);
|
|
12
|
+
}, options);
|
|
13
|
+
}
|
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import { type ValidationOptions } from '../../core/index.js';
|
|
2
|
-
export interface IsTimeOptions extends ValidationOptions {
|
|
3
|
-
}
|
|
4
2
|
/**
|
|
5
3
|
* Validates if value is a time formatted string
|
|
6
4
|
* @validator isTime
|
|
7
5
|
*/
|
|
8
|
-
export declare function isTime(options?:
|
|
6
|
+
export declare function isTime(options?: isTime.Options): import("../../core/validator.js").Validator<string, string | Date, import("../../core/types.js").ExecutionOptions>;
|
|
7
|
+
export declare namespace isTime {
|
|
8
|
+
interface Options extends ValidationOptions {
|
|
9
|
+
}
|
|
10
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { type ValidationOptions } from '../../core/index.js';
|
|
2
|
+
/**
|
|
3
|
+
* Validates if value a Uppercase string
|
|
4
|
+
* @validator isUppercase
|
|
5
|
+
*/
|
|
6
|
+
export declare function isUppercase(options?: isUppercase.Options): import("../../core/validator.js").Validator<string, string, import("../../core/types.js").ExecutionOptions>;
|
|
7
|
+
export declare namespace isUppercase {
|
|
8
|
+
interface Options extends ValidationOptions {
|
|
9
|
+
}
|
|
10
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import validatorJS from '@browsery/validator';
|
|
2
|
+
import { validator, } from '../../core/index.js';
|
|
3
|
+
/**
|
|
4
|
+
* Validates if value a Uppercase string
|
|
5
|
+
* @validator isUppercase
|
|
6
|
+
*/
|
|
7
|
+
export function isUppercase(options) {
|
|
8
|
+
return validator('isUppercase', (input, context, _this) => {
|
|
9
|
+
if (typeof input === 'string' && validatorJS.isUppercase(input)) {
|
|
10
|
+
return input;
|
|
11
|
+
}
|
|
12
|
+
context.fail(_this, `Value must be an uppercase string`, input);
|
|
13
|
+
}, options);
|
|
14
|
+
}
|
|
@@ -1,9 +1,11 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { type IsURLOptions as _IsURLOptions } from '@browsery/validator';
|
|
2
2
|
import { type ValidationOptions } from '../../core/index.js';
|
|
3
|
-
export interface IsURLOptions extends ValidationOptions, validatorJS.IsURLOptions {
|
|
4
|
-
}
|
|
5
3
|
/**
|
|
6
4
|
* Validates if value is an URL
|
|
7
5
|
* @validator isURL
|
|
8
6
|
*/
|
|
9
|
-
export declare function isURL(options?:
|
|
7
|
+
export declare function isURL(options?: isURL.Options): import("../../core/validator.js").Validator<string, string, import("../../core/types.js").ExecutionOptions>;
|
|
8
|
+
export declare namespace isURL {
|
|
9
|
+
interface Options extends ValidationOptions, _IsURLOptions {
|
|
10
|
+
}
|
|
11
|
+
}
|
|
@@ -1,6 +1,12 @@
|
|
|
1
|
+
import { type UUIDVersion as _UUIDVersion } from '@browsery/validator';
|
|
1
2
|
import { type ValidationOptions } from '../../core/index.js';
|
|
2
3
|
/**
|
|
3
|
-
* Validates if value is
|
|
4
|
+
* Validates if value is a "UUID".
|
|
4
5
|
* @validator isUUID
|
|
5
6
|
*/
|
|
6
|
-
export declare function isUUID(version?:
|
|
7
|
+
export declare function isUUID(version?: isUUID.UUIDVersion, options?: isUUID.Options): import("../../core/validator.js").Validator<string, string, import("../../core/types.js").ExecutionOptions>;
|
|
8
|
+
export declare namespace isUUID {
|
|
9
|
+
type UUIDVersion = _UUIDVersion;
|
|
10
|
+
interface Options extends ValidationOptions {
|
|
11
|
+
}
|
|
12
|
+
}
|
|
@@ -1,6 +1,12 @@
|
|
|
1
|
+
import { type VATCountryCode as _VATCountryCode } from '@browsery/validator';
|
|
1
2
|
import { type ValidationOptions } from '../../core/index.js';
|
|
2
3
|
/**
|
|
3
|
-
* Validates if value is
|
|
4
|
+
* Validates if value is a VAT number
|
|
4
5
|
* @validator isVAT
|
|
5
6
|
*/
|
|
6
|
-
export declare function isVATNumber(countryCode:
|
|
7
|
+
export declare function isVATNumber(countryCode: isVATNumber.CountryCode, options?: isVATNumber.Options): import("../../core/validator.js").Validator<string, string, import("../../core/types.js").ExecutionOptions>;
|
|
8
|
+
export declare namespace isVATNumber {
|
|
9
|
+
type CountryCode = _VATCountryCode;
|
|
10
|
+
interface Options extends ValidationOptions {
|
|
11
|
+
}
|
|
12
|
+
}
|
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
import { type ValidationOptions } from '../../core/index.js';
|
|
2
|
-
export interface IsRegExpOptions extends ValidationOptions {
|
|
3
|
-
formatName?: string;
|
|
4
|
-
}
|
|
5
2
|
/**
|
|
6
3
|
* Coerces given value to "UUID" format or returns undefined if nullish
|
|
7
4
|
* @validator uuid
|
|
8
5
|
*/
|
|
9
|
-
export declare function matches(format: string | RegExp, options?:
|
|
6
|
+
export declare function matches(format: string | RegExp, options?: matches.Options): import("../../core/validator.js").Validator<string, string, import("../../core/types.js").ExecutionOptions>;
|
|
7
|
+
export declare namespace matches {
|
|
8
|
+
interface Options extends ValidationOptions {
|
|
9
|
+
formatName?: string;
|
|
10
|
+
}
|
|
11
|
+
}
|
package/rules/index.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
export * from './format-rules/is-alpha.js';
|
|
2
|
+
export * from './format-rules/is-alphanumeric.js';
|
|
2
3
|
export * from './format-rules/is-ascii.js';
|
|
3
4
|
export * from './format-rules/is-base64.js';
|
|
4
5
|
export * from './format-rules/is-btc-address.js';
|
|
@@ -21,7 +22,9 @@ export * from './format-rules/is-mobile-phone.js';
|
|
|
21
22
|
export * from './format-rules/is-object-id.js';
|
|
22
23
|
export * from './format-rules/is-passport-number.js';
|
|
23
24
|
export * from './format-rules/is-port.js';
|
|
25
|
+
export * from './format-rules/is-swift.js';
|
|
24
26
|
export * from './format-rules/is-time.js';
|
|
27
|
+
export * from './format-rules/is-uppercase.js';
|
|
25
28
|
export * from './format-rules/is-url.js';
|
|
26
29
|
export * from './format-rules/is-uuid.js';
|
|
27
30
|
export * from './format-rules/is-vat-number.js';
|
|
@@ -29,6 +32,11 @@ export * from './format-rules/matches.js';
|
|
|
29
32
|
export * from './logical-rules/is-defined.js';
|
|
30
33
|
export * from './logical-rules/is-empty.js';
|
|
31
34
|
export * from './logical-rules/is-equal.js';
|
|
35
|
+
export * from './logical-rules/is-gt.js';
|
|
36
|
+
export * from './logical-rules/is-gte.js';
|
|
37
|
+
export * from './logical-rules/is-lt.js';
|
|
38
|
+
export * from './logical-rules/is-lte.js';
|
|
39
|
+
export * from './logical-rules/length.js';
|
|
32
40
|
export * from './logical-rules/range.js';
|
|
33
41
|
export * from './type-rules/is-any.js';
|
|
34
42
|
export * from './type-rules/is-array.js';
|
|
@@ -51,3 +59,4 @@ export * from './utility-rules/one-of.js';
|
|
|
51
59
|
export * from './utility-rules/optional.js';
|
|
52
60
|
export * from './utility-rules/pipe.js';
|
|
53
61
|
export * from './utility-rules/required.js';
|
|
62
|
+
export * from './utility-rules/string-utils.js';
|
package/rules/index.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
export * from './format-rules/is-alpha.js';
|
|
2
|
+
export * from './format-rules/is-alphanumeric.js';
|
|
2
3
|
export * from './format-rules/is-ascii.js';
|
|
3
4
|
export * from './format-rules/is-base64.js';
|
|
4
5
|
export * from './format-rules/is-btc-address.js';
|
|
@@ -21,7 +22,9 @@ export * from './format-rules/is-mobile-phone.js';
|
|
|
21
22
|
export * from './format-rules/is-object-id.js';
|
|
22
23
|
export * from './format-rules/is-passport-number.js';
|
|
23
24
|
export * from './format-rules/is-port.js';
|
|
25
|
+
export * from './format-rules/is-swift.js';
|
|
24
26
|
export * from './format-rules/is-time.js';
|
|
27
|
+
export * from './format-rules/is-uppercase.js';
|
|
25
28
|
export * from './format-rules/is-url.js';
|
|
26
29
|
export * from './format-rules/is-uuid.js';
|
|
27
30
|
export * from './format-rules/is-vat-number.js';
|
|
@@ -29,6 +32,11 @@ export * from './format-rules/matches.js';
|
|
|
29
32
|
export * from './logical-rules/is-defined.js';
|
|
30
33
|
export * from './logical-rules/is-empty.js';
|
|
31
34
|
export * from './logical-rules/is-equal.js';
|
|
35
|
+
export * from './logical-rules/is-gt.js';
|
|
36
|
+
export * from './logical-rules/is-gte.js';
|
|
37
|
+
export * from './logical-rules/is-lt.js';
|
|
38
|
+
export * from './logical-rules/is-lte.js';
|
|
39
|
+
export * from './logical-rules/length.js';
|
|
32
40
|
export * from './logical-rules/range.js';
|
|
33
41
|
export * from './type-rules/is-any.js';
|
|
34
42
|
export * from './type-rules/is-array.js';
|
|
@@ -51,3 +59,4 @@ export * from './utility-rules/one-of.js';
|
|
|
51
59
|
export * from './utility-rules/optional.js';
|
|
52
60
|
export * from './utility-rules/pipe.js';
|
|
53
61
|
export * from './utility-rules/required.js';
|
|
62
|
+
export * from './utility-rules/string-utils.js';
|
|
@@ -3,4 +3,8 @@ import { type ValidationOptions } from '../../core/index.js';
|
|
|
3
3
|
* Validates if value is not "undefined" nor "null"
|
|
4
4
|
* @validator isDefined
|
|
5
5
|
*/
|
|
6
|
-
export declare function isDefined(options?:
|
|
6
|
+
export declare function isDefined(options?: isDefined.Options): import("../../core/validator.js").Validator<any, unknown, import("../../core/types.js").ExecutionOptions>;
|
|
7
|
+
export declare namespace isDefined {
|
|
8
|
+
interface Options extends ValidationOptions {
|
|
9
|
+
}
|
|
10
|
+
}
|
|
@@ -1,11 +1,19 @@
|
|
|
1
1
|
import { type ValidationOptions } from '../../core/index.js';
|
|
2
2
|
/**
|
|
3
|
-
* Checks if value is
|
|
3
|
+
* Checks if the value is empty. Value should be string, array, set, map or object
|
|
4
4
|
* @validator isEmpty
|
|
5
5
|
*/
|
|
6
|
-
export declare function isEmpty(options?:
|
|
6
|
+
export declare function isEmpty(options?: isEmpty.Options): import("../../core/validator.js").Validator<any, any, import("../../core/types.js").ExecutionOptions>;
|
|
7
|
+
export declare namespace isEmpty {
|
|
8
|
+
interface Options extends ValidationOptions {
|
|
9
|
+
}
|
|
10
|
+
}
|
|
7
11
|
/**
|
|
8
|
-
* Checks if value is
|
|
12
|
+
* Checks if the value is not empty. Value should be string, array, set, map or object
|
|
9
13
|
* @validator isNotEmpty
|
|
10
14
|
*/
|
|
11
|
-
export declare function isNotEmpty(options?:
|
|
15
|
+
export declare function isNotEmpty(options?: isNotEmpty.Options): import("../../core/validator.js").Validator<any, any, import("../../core/types.js").ExecutionOptions>;
|
|
16
|
+
export declare namespace isNotEmpty {
|
|
17
|
+
interface Options extends ValidationOptions {
|
|
18
|
+
}
|
|
19
|
+
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { validator, } from '../../core/index.js';
|
|
2
2
|
/**
|
|
3
|
-
* Checks if value is
|
|
3
|
+
* Checks if the value is empty. Value should be string, array, set, map or object
|
|
4
4
|
* @validator isEmpty
|
|
5
5
|
*/
|
|
6
6
|
export function isEmpty(options) {
|
|
@@ -48,7 +48,7 @@ export function isEmpty(options) {
|
|
|
48
48
|
}, options);
|
|
49
49
|
}
|
|
50
50
|
/**
|
|
51
|
-
* Checks if value is
|
|
51
|
+
* Checks if the value is not empty. Value should be string, array, set, map or object
|
|
52
52
|
* @validator isNotEmpty
|
|
53
53
|
*/
|
|
54
54
|
export function isNotEmpty(options) {
|
|
@@ -3,9 +3,17 @@ import { type ValidationOptions } from '../../core/index.js';
|
|
|
3
3
|
*
|
|
4
4
|
* @validator isEqual
|
|
5
5
|
*/
|
|
6
|
-
export declare function isEqual<T>(compare: T, options?:
|
|
6
|
+
export declare function isEqual<T>(compare: T, options?: isEqual.Options): import("../../core/validator.js").Validator<any, any, import("../../core/types.js").ExecutionOptions>;
|
|
7
|
+
export declare namespace isEqual {
|
|
8
|
+
interface Options extends ValidationOptions {
|
|
9
|
+
}
|
|
10
|
+
}
|
|
7
11
|
/**
|
|
8
12
|
*
|
|
9
13
|
* @validator isNotEqual
|
|
10
14
|
*/
|
|
11
|
-
export declare function isNotEqual(compare: any, options?:
|
|
15
|
+
export declare function isNotEqual(compare: any, options?: isNotEqual.Options): import("../../core/validator.js").Validator<any, any, import("../../core/types.js").ExecutionOptions>;
|
|
16
|
+
export declare namespace isNotEqual {
|
|
17
|
+
interface Options extends ValidationOptions {
|
|
18
|
+
}
|
|
19
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { type ValidationOptions, type Validator } from '../../core/index.js';
|
|
2
|
+
import type { range } from './range.js';
|
|
3
|
+
/**
|
|
4
|
+
* Checks if value is grater than "minValue"
|
|
5
|
+
* @validator iGt
|
|
6
|
+
*/
|
|
7
|
+
export declare function isGt<T extends range.Input>(minValue: T, options?: isGt.Options): Validator;
|
|
8
|
+
export declare namespace isGt {
|
|
9
|
+
interface Options extends ValidationOptions {
|
|
10
|
+
caseInsensitive?: boolean;
|
|
11
|
+
}
|
|
12
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { validator, } from '../../core/index.js';
|
|
2
|
+
/**
|
|
3
|
+
* Checks if value is grater than "minValue"
|
|
4
|
+
* @validator iGt
|
|
5
|
+
*/
|
|
6
|
+
export function isGt(minValue, options) {
|
|
7
|
+
return validator('isGt', (input, context, _this) => {
|
|
8
|
+
if ((typeof minValue === 'number' || typeof minValue === 'bigint') &&
|
|
9
|
+
(typeof input === 'number' || typeof input === 'bigint') &&
|
|
10
|
+
input > minValue) {
|
|
11
|
+
return input;
|
|
12
|
+
}
|
|
13
|
+
if (minValue instanceof Date &&
|
|
14
|
+
input instanceof Date &&
|
|
15
|
+
input > minValue) {
|
|
16
|
+
return input;
|
|
17
|
+
}
|
|
18
|
+
if (typeof minValue === 'string' &&
|
|
19
|
+
typeof input === 'string' &&
|
|
20
|
+
(input > minValue ||
|
|
21
|
+
(options?.caseInsensitive &&
|
|
22
|
+
input.toLowerCase() > minValue.toLowerCase()))) {
|
|
23
|
+
return input;
|
|
24
|
+
}
|
|
25
|
+
context.fail(_this, `Value must be greater than ${typeof minValue === 'string' ? `"${minValue}"` : minValue}`, input);
|
|
26
|
+
}, options);
|
|
27
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { type ValidationOptions, type Validator } from '../../core/index.js';
|
|
2
|
+
import type { range } from './range.js';
|
|
3
|
+
/**
|
|
4
|
+
* Checks if value is grater than or equal to minValue
|
|
5
|
+
* @validator isGte
|
|
6
|
+
*/
|
|
7
|
+
export declare function isGte<T extends range.Input>(minValue: T, options?: isGte.Options): Validator<T, T>;
|
|
8
|
+
export declare namespace isGte {
|
|
9
|
+
interface Options extends ValidationOptions {
|
|
10
|
+
caseInsensitive?: boolean;
|
|
11
|
+
}
|
|
12
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { validator, } from '../../core/index.js';
|
|
2
|
+
/**
|
|
3
|
+
* Checks if value is grater than or equal to minValue
|
|
4
|
+
* @validator isGte
|
|
5
|
+
*/
|
|
6
|
+
export function isGte(minValue, options) {
|
|
7
|
+
return validator('isGte', (input, context, _this) => {
|
|
8
|
+
if ((typeof minValue === 'number' || typeof minValue === 'bigint') &&
|
|
9
|
+
(typeof input === 'number' || typeof input === 'bigint') &&
|
|
10
|
+
input >= minValue) {
|
|
11
|
+
return input;
|
|
12
|
+
}
|
|
13
|
+
if (minValue instanceof Date &&
|
|
14
|
+
input instanceof Date &&
|
|
15
|
+
input >= minValue) {
|
|
16
|
+
return input;
|
|
17
|
+
}
|
|
18
|
+
if (typeof minValue === 'string' &&
|
|
19
|
+
typeof input === 'string' &&
|
|
20
|
+
(input >= minValue ||
|
|
21
|
+
(options?.caseInsensitive &&
|
|
22
|
+
input.toLowerCase() >= minValue.toLowerCase()))) {
|
|
23
|
+
return input;
|
|
24
|
+
}
|
|
25
|
+
context.fail(_this, `Value must be greater than or equal to ${typeof minValue === 'string' ? `"${minValue}"` : minValue}`, input);
|
|
26
|
+
}, options);
|
|
27
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { type ValidationOptions, type Validator } from '../../core/index.js';
|
|
2
|
+
import type { range } from './range.js';
|
|
3
|
+
/**
|
|
4
|
+
* Checks if the value is lover than maxValue
|
|
5
|
+
* @validator isLt
|
|
6
|
+
*/
|
|
7
|
+
export declare function isLt<T extends range.Input>(maxValue: T, options?: isLt.Options): Validator;
|
|
8
|
+
export declare namespace isLt {
|
|
9
|
+
interface Options extends ValidationOptions {
|
|
10
|
+
caseInsensitive?: boolean;
|
|
11
|
+
}
|
|
12
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { validator, } from '../../core/index.js';
|
|
2
|
+
/**
|
|
3
|
+
* Checks if the value is lover than maxValue
|
|
4
|
+
* @validator isLt
|
|
5
|
+
*/
|
|
6
|
+
export function isLt(maxValue, options) {
|
|
7
|
+
return validator('isLt', (input, context, _this) => {
|
|
8
|
+
if ((typeof maxValue === 'number' || typeof maxValue === 'bigint') &&
|
|
9
|
+
(typeof input === 'number' || typeof input === 'bigint') &&
|
|
10
|
+
input < maxValue) {
|
|
11
|
+
return input;
|
|
12
|
+
}
|
|
13
|
+
if (maxValue instanceof Date &&
|
|
14
|
+
input instanceof Date &&
|
|
15
|
+
input < maxValue) {
|
|
16
|
+
return input;
|
|
17
|
+
}
|
|
18
|
+
if (typeof maxValue === 'string' &&
|
|
19
|
+
typeof input === 'string' &&
|
|
20
|
+
(input < maxValue ||
|
|
21
|
+
(options?.caseInsensitive &&
|
|
22
|
+
input.toLowerCase() < maxValue.toLowerCase()))) {
|
|
23
|
+
return input;
|
|
24
|
+
}
|
|
25
|
+
context.fail(_this, `Value must be lover than ${typeof maxValue === 'string' ? `"${maxValue}"` : maxValue}`, input);
|
|
26
|
+
}, options);
|
|
27
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { type ValidationOptions, type Validator } from '../../core/index.js';
|
|
2
|
+
import type { range } from './range.js';
|
|
3
|
+
/**
|
|
4
|
+
* Checks if the value is lover than or equal to maxValue
|
|
5
|
+
* @validator isLte
|
|
6
|
+
*/
|
|
7
|
+
export declare function isLte<T extends range.Input>(maxValue: T, options?: isLte.Options): Validator;
|
|
8
|
+
export declare namespace isLte {
|
|
9
|
+
interface Options extends ValidationOptions {
|
|
10
|
+
caseInsensitive?: boolean;
|
|
11
|
+
}
|
|
12
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { validator, } from '../../core/index.js';
|
|
2
|
+
/**
|
|
3
|
+
* Checks if the value is lover than or equal to maxValue
|
|
4
|
+
* @validator isLte
|
|
5
|
+
*/
|
|
6
|
+
export function isLte(maxValue, options) {
|
|
7
|
+
return validator('isLte', (input, context, _this) => {
|
|
8
|
+
if ((typeof maxValue === 'number' || typeof maxValue === 'bigint') &&
|
|
9
|
+
(typeof input === 'number' || typeof input === 'bigint') &&
|
|
10
|
+
input <= maxValue) {
|
|
11
|
+
return input;
|
|
12
|
+
}
|
|
13
|
+
if (maxValue instanceof Date &&
|
|
14
|
+
input instanceof Date &&
|
|
15
|
+
input <= maxValue) {
|
|
16
|
+
return input;
|
|
17
|
+
}
|
|
18
|
+
if (typeof maxValue === 'string' &&
|
|
19
|
+
typeof input === 'string' &&
|
|
20
|
+
(input <= maxValue ||
|
|
21
|
+
(options?.caseInsensitive &&
|
|
22
|
+
input.toLowerCase() <= maxValue.toLowerCase()))) {
|
|
23
|
+
return input;
|
|
24
|
+
}
|
|
25
|
+
context.fail(_this, `Value must be lover than or equal to ${typeof maxValue === 'string' ? `"${maxValue}"` : maxValue}`, input);
|
|
26
|
+
}, options);
|
|
27
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Checks the length is at least "minValue"
|
|
3
|
+
* @validator lengthMin
|
|
4
|
+
*/
|
|
5
|
+
export declare const lengthMin: (minValue: number) => import("../../index.js").Validator<any, any, import("../../index.js").ExecutionOptions>;
|
|
6
|
+
/**
|
|
7
|
+
* Checks if the length is at most "maxValue"
|
|
8
|
+
* @validator lengthMax
|
|
9
|
+
*/
|
|
10
|
+
export declare const lengthMax: (maxValue: number) => import("../../index.js").Validator<any, any, import("../../index.js").ExecutionOptions>;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { allOf } from '../utility-rules/all-of.js';
|
|
2
|
+
import { getLength } from '../utility-rules/get-length.js';
|
|
3
|
+
import { pipe } from '../utility-rules/pipe.js';
|
|
4
|
+
import { isGte } from './is-gte.js';
|
|
5
|
+
import { isLte } from './is-lte.js';
|
|
6
|
+
/**
|
|
7
|
+
* Checks the length is at least "minValue"
|
|
8
|
+
* @validator lengthMin
|
|
9
|
+
*/
|
|
10
|
+
export const lengthMin = (minValue) => allOf([
|
|
11
|
+
pipe([
|
|
12
|
+
getLength(),
|
|
13
|
+
isGte(minValue, {
|
|
14
|
+
onFail: () => `Value length must be at least ${minValue}`,
|
|
15
|
+
}),
|
|
16
|
+
]),
|
|
17
|
+
]);
|
|
18
|
+
/**
|
|
19
|
+
* Checks if the length is at most "maxValue"
|
|
20
|
+
* @validator lengthMax
|
|
21
|
+
*/
|
|
22
|
+
export const lengthMax = (maxValue) => allOf([
|
|
23
|
+
pipe([
|
|
24
|
+
getLength(),
|
|
25
|
+
isLte(maxValue, {
|
|
26
|
+
onFail: () => `The length of {{label}} must be at most ${maxValue}`,
|
|
27
|
+
}),
|
|
28
|
+
]),
|
|
29
|
+
]);
|
|
@@ -1,46 +1,10 @@
|
|
|
1
|
-
import { type ValidationOptions
|
|
2
|
-
type RangeInput = number | bigint | Date | string;
|
|
1
|
+
import { type ValidationOptions } from '../../core/index.js';
|
|
3
2
|
/**
|
|
4
3
|
* Checks if value is between minValue and maxValue
|
|
5
4
|
* @validator range
|
|
6
5
|
*/
|
|
7
|
-
export declare function range<T extends
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
export declare function isGt<T extends RangeInput>(minValue: T, options?: ValidationOptions & {
|
|
13
|
-
caseInsensitive?: boolean;
|
|
14
|
-
}): Validator;
|
|
15
|
-
/**
|
|
16
|
-
* Checks if value is grater than or equal to minValue
|
|
17
|
-
* @validator isGte
|
|
18
|
-
*/
|
|
19
|
-
export declare function isGte<T extends RangeInput>(minValue: T, options?: ValidationOptions & {
|
|
20
|
-
caseInsensitive?: boolean;
|
|
21
|
-
}): Validator<T, T>;
|
|
22
|
-
/**
|
|
23
|
-
* Checks if number value is lover than maxValue
|
|
24
|
-
* @validator isLt
|
|
25
|
-
*/
|
|
26
|
-
export declare function isLt<T extends RangeInput>(maxValue: T, options?: ValidationOptions & {
|
|
27
|
-
caseInsensitive?: boolean;
|
|
28
|
-
}): Validator;
|
|
29
|
-
/**
|
|
30
|
-
* Checks if value is lover than or equal to maxValue
|
|
31
|
-
* @validator isLte
|
|
32
|
-
*/
|
|
33
|
-
export declare function isLte<T extends RangeInput>(maxValue: T, options?: ValidationOptions & {
|
|
34
|
-
caseInsensitive?: boolean;
|
|
35
|
-
}): Validator;
|
|
36
|
-
/**
|
|
37
|
-
* Checks the length is at least "minValue"
|
|
38
|
-
* @validator lengthMin
|
|
39
|
-
*/
|
|
40
|
-
export declare const lengthMin: (minValue: number) => Validator<any, any, import("../../core/types.js").ExecutionOptions>;
|
|
41
|
-
/**
|
|
42
|
-
* Checks if the length is at most "maxValue"
|
|
43
|
-
* @validator lengthMax
|
|
44
|
-
*/
|
|
45
|
-
export declare const lengthMax: (maxValue: number) => Validator<any, any, import("../../core/types.js").ExecutionOptions>;
|
|
46
|
-
export {};
|
|
6
|
+
export declare function range<T extends range.Input>(minValue: T, maxValue: T, options?: range.Options): import("../../core/validator.js").Validator<T, T, import("../../core/types.js").ExecutionOptions>;
|
|
7
|
+
export declare namespace range {
|
|
8
|
+
type Input = number | bigint | Date | string;
|
|
9
|
+
type Options = ValidationOptions;
|
|
10
|
+
}
|