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
package/constants.js
CHANGED
package/index.d.ts
CHANGED
|
@@ -1,10 +1,7 @@
|
|
|
1
1
|
import { Context, ExecutionOptions } from './core/index.js';
|
|
2
|
-
import { DatePrecision } from './rules/index.js';
|
|
3
2
|
import * as vg from './rules/index.js';
|
|
4
3
|
export * from './constants.js';
|
|
5
4
|
export * from './core/index.js';
|
|
6
|
-
export type { DatePrecision } from './rules/type-rules/is-date.js';
|
|
7
|
-
export type { IsObject } from './rules/type-rules/is-object.js';
|
|
8
5
|
declare const isAlpha: import("./core/validator.js").Validator<string, string, ExecutionOptions>;
|
|
9
6
|
declare const isAlphanumeric: import("./core/validator.js").Validator<string, string, ExecutionOptions>;
|
|
10
7
|
declare const isAny: import("./core/validator.js").Validator<any, any, ExecutionOptions>;
|
|
@@ -41,8 +38,8 @@ declare const isNotNullish: import("./core/validator.js").Validator<unknown, unk
|
|
|
41
38
|
declare const isNull: import("./core/validator.js").Validator<null, unknown, ExecutionOptions>;
|
|
42
39
|
declare const isNullish: import("./core/validator.js").Validator<null, unknown, ExecutionOptions>;
|
|
43
40
|
declare const isNumber: import("./core/validator.js").Validator<number, unknown, ExecutionOptions>;
|
|
44
|
-
declare const isObject: vg.
|
|
45
|
-
declare const isObjectId: import("./core/validator.js").Validator<string | vg.ObjectIdLike
|
|
41
|
+
declare const isObject: vg.isObject.Validator<object, string | object>;
|
|
42
|
+
declare const isObjectId: import("./core/validator.js").Validator<string | Uint8Array<ArrayBufferLike> | vg.isObjectId.ObjectIdLike, unknown, ExecutionOptions>;
|
|
46
43
|
declare const isPort: import("./core/validator.js").Validator<number, string | number, ExecutionOptions>;
|
|
47
44
|
declare const isString: import("./core/validator.js").Validator<string, unknown, ExecutionOptions>;
|
|
48
45
|
declare const isSWIFT: import("./core/validator.js").Validator<string, string, ExecutionOptions>;
|
|
@@ -56,15 +53,18 @@ declare const isUUID2: import("./core/validator.js").Validator<string, string, E
|
|
|
56
53
|
declare const isUUID3: import("./core/validator.js").Validator<string, string, ExecutionOptions>;
|
|
57
54
|
declare const isUUID4: import("./core/validator.js").Validator<string, string, ExecutionOptions>;
|
|
58
55
|
declare const isUUID5: import("./core/validator.js").Validator<string, string, ExecutionOptions>;
|
|
56
|
+
declare const isUUID6: import("./core/validator.js").Validator<string, string, ExecutionOptions>;
|
|
57
|
+
declare const isUUID7: import("./core/validator.js").Validator<string, string, ExecutionOptions>;
|
|
58
|
+
declare const isUUID8: import("./core/validator.js").Validator<string, string, ExecutionOptions>;
|
|
59
59
|
declare const toArray: import("./core/validator.js").Validator<any[], any, ExecutionOptions>;
|
|
60
60
|
declare const toBigint: import("./core/validator.js").Validator<bigint, unknown, ExecutionOptions>;
|
|
61
61
|
declare const toBoolean: import("./core/validator.js").Validator<boolean | undefined, unknown, ExecutionOptions>;
|
|
62
62
|
declare const toDate: import("./core/validator.js").Validator<Date, string | number | Date, ExecutionOptions>;
|
|
63
63
|
declare const toDateString: (input: Date | string | number, options?: ExecutionOptions & {
|
|
64
|
-
trim?:
|
|
64
|
+
trim?: vg.isDateString.Precision;
|
|
65
65
|
}, ctx?: Context) => any;
|
|
66
66
|
declare const toInteger: import("./core/validator.js").Validator<number, unknown, ExecutionOptions>;
|
|
67
67
|
declare const toNumber: import("./core/validator.js").Validator<number, unknown, ExecutionOptions>;
|
|
68
68
|
declare const toString: import("./core/validator.js").Validator<string, unknown, ExecutionOptions>;
|
|
69
69
|
declare const toTime: import("./core/validator.js").Validator<string, string | Date, ExecutionOptions>;
|
|
70
|
-
export { isAlpha, isAlphanumeric, isAny, isArray, isAscii, isBase64, isBigint, isBoolean, isBtcAddress, isCreditCard, isDate, isDateString, isDecimal, isDefined, isEAN, isEmail, isEmpty, isETHAddress, isFQDN, isHex, isHexColor, isIBAN, isInteger, isIP, isIPRange, isISSN, isJWT, isLowercase, isMACAddress, isMobilePhone, isNotEmpty, isNotNull, isNotNullish, isNull, isNullish, isNumber, isObject, isObjectId, isPort, isString, isSWIFT, isTime, isUndefined, isUppercase, isURL, isUUID, isUUID1, isUUID2, isUUID3, isUUID4, isUUID5, toArray, toBigint, toBoolean, toDate, toDateString, toInteger, toNumber, toString, toTime, vg, };
|
|
70
|
+
export { isAlpha, isAlphanumeric, isAny, isArray, isAscii, isBase64, isBigint, isBoolean, isBtcAddress, isCreditCard, isDate, isDateString, isDecimal, isDefined, isEAN, isEmail, isEmpty, isETHAddress, isFQDN, isHex, isHexColor, isIBAN, isInteger, isIP, isIPRange, isISSN, isJWT, isLowercase, isMACAddress, isMobilePhone, isNotEmpty, isNotNull, isNotNullish, isNull, isNullish, isNumber, isObject, isObjectId, isPort, isString, isSWIFT, isTime, isUndefined, isUppercase, isURL, isUUID, isUUID1, isUUID2, isUUID3, isUUID4, isUUID5, isUUID6, isUUID7, isUUID8, toArray, toBigint, toBoolean, toDate, toDateString, toInteger, toNumber, toString, toTime, vg, };
|
package/index.js
CHANGED
|
@@ -52,21 +52,24 @@ const isUUID2 = vg.isUUID(2);
|
|
|
52
52
|
const isUUID3 = vg.isUUID(3);
|
|
53
53
|
const isUUID4 = vg.isUUID(4);
|
|
54
54
|
const isUUID5 = vg.isUUID(5);
|
|
55
|
+
const isUUID6 = vg.isUUID(6);
|
|
56
|
+
const isUUID7 = vg.isUUID(7);
|
|
57
|
+
const isUUID8 = vg.isUUID(8);
|
|
55
58
|
const toArray = vg.isArray(isAny, { coerce: true });
|
|
56
59
|
const toBigint = vg.isBigint({ coerce: true });
|
|
57
60
|
const toBoolean = vg.isBoolean({ coerce: true });
|
|
58
61
|
const toDate = vg.isDate({ coerce: true });
|
|
59
62
|
const toDateStringValidators = new Map();
|
|
60
63
|
const toDateString = (input, options, ctx) => {
|
|
61
|
-
const
|
|
62
|
-
let validator = toDateStringValidators.get(
|
|
64
|
+
const precisionMax = options?.trim ?? 'ms';
|
|
65
|
+
let validator = toDateStringValidators.get(precisionMax);
|
|
63
66
|
if (!validator) {
|
|
64
67
|
validator = vg.isDateString({
|
|
65
68
|
coerce: true,
|
|
66
|
-
precisionMax
|
|
69
|
+
precisionMax,
|
|
67
70
|
trim: true,
|
|
68
71
|
});
|
|
69
|
-
toDateStringValidators.set(
|
|
72
|
+
toDateStringValidators.set(precisionMax, validator);
|
|
70
73
|
}
|
|
71
74
|
return validator(input, options, ctx);
|
|
72
75
|
};
|
|
@@ -74,4 +77,4 @@ const toInteger = vg.isInteger({ coerce: true });
|
|
|
74
77
|
const toNumber = vg.isNumber({ coerce: true });
|
|
75
78
|
const toString = vg.isString({ coerce: true });
|
|
76
79
|
const toTime = vg.isTime({ coerce: true });
|
|
77
|
-
export { isAlpha, isAlphanumeric, isAny, isArray, isAscii, isBase64, isBigint, isBoolean, isBtcAddress, isCreditCard, isDate, isDateString, isDecimal, isDefined, isEAN, isEmail, isEmpty, isETHAddress, isFQDN, isHex, isHexColor, isIBAN, isInteger, isIP, isIPRange, isISSN, isJWT, isLowercase, isMACAddress, isMobilePhone, isNotEmpty, isNotNull, isNotNullish, isNull, isNullish, isNumber, isObject, isObjectId, isPort, isString, isSWIFT, isTime, isUndefined, isUppercase, isURL, isUUID, isUUID1, isUUID2, isUUID3, isUUID4, isUUID5, toArray, toBigint, toBoolean, toDate, toDateString, toInteger, toNumber, toString, toTime, vg, };
|
|
80
|
+
export { isAlpha, isAlphanumeric, isAny, isArray, isAscii, isBase64, isBigint, isBoolean, isBtcAddress, isCreditCard, isDate, isDateString, isDecimal, isDefined, isEAN, isEmail, isEmpty, isETHAddress, isFQDN, isHex, isHexColor, isIBAN, isInteger, isIP, isIPRange, isISSN, isJWT, isLowercase, isMACAddress, isMobilePhone, isNotEmpty, isNotNull, isNotNullish, isNull, isNullish, isNumber, isObject, isObjectId, isPort, isString, isSWIFT, isTime, isUndefined, isUppercase, isURL, isUUID, isUUID1, isUUID2, isUUID3, isUUID4, isUUID5, isUUID6, isUUID7, isUUID8, toArray, toBigint, toBoolean, toDate, toDateString, toInteger, toNumber, toString, toTime, vg, };
|
package/package.json
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "valgen",
|
|
3
3
|
"description": "Fast runtime type validator, converter and io (encoding/decoding) library",
|
|
4
|
-
"version": "
|
|
4
|
+
"version": "6.0.0",
|
|
5
5
|
"author": "Panates",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"dependencies": {
|
|
8
|
-
"@browsery/validator": "^13.15.
|
|
8
|
+
"@browsery/validator": "^13.15.35",
|
|
9
9
|
"date-fns": "^4.1.0",
|
|
10
10
|
"reflect-metadata": "^0.2.2",
|
|
11
|
-
"ts-gems": "^3.11.
|
|
11
|
+
"ts-gems": "^3.11.6",
|
|
12
12
|
"tslib": "^2.8.1"
|
|
13
13
|
},
|
|
14
14
|
"type": "module",
|
|
@@ -3,9 +3,8 @@ import { type ValidationOptions } from '../../core/index.js';
|
|
|
3
3
|
* Check if the string contains only letters (a-zA-Z).
|
|
4
4
|
* @validator isAlpha
|
|
5
5
|
*/
|
|
6
|
-
export declare function isAlpha(options?:
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
export declare function isAlphanumeric(options?: ValidationOptions): import("../../core/validator.js").Validator<string, string, import("../../core/types.js").ExecutionOptions>;
|
|
6
|
+
export declare function isAlpha(options?: isAlpha.Options): import("../../core/validator.js").Validator<string, string, import("../../core/types.js").ExecutionOptions>;
|
|
7
|
+
export declare namespace isAlpha {
|
|
8
|
+
interface Options extends ValidationOptions {
|
|
9
|
+
}
|
|
10
|
+
}
|
|
@@ -5,21 +5,9 @@ import { validator, } from '../../core/index.js';
|
|
|
5
5
|
* @validator isAlpha
|
|
6
6
|
*/
|
|
7
7
|
export function isAlpha(options) {
|
|
8
|
-
return validator('
|
|
8
|
+
return validator('isAlpha', (input, context, _this) => {
|
|
9
9
|
if (typeof input === 'string' && validatorJS.isAlpha(input))
|
|
10
10
|
return input;
|
|
11
11
|
context.fail(_this, `"Value must be an alpha string`, input);
|
|
12
12
|
}, options);
|
|
13
13
|
}
|
|
14
|
-
/**
|
|
15
|
-
* Check if the string contains only letters and numbers.
|
|
16
|
-
* @validator isAlphanumeric
|
|
17
|
-
*/
|
|
18
|
-
export function isAlphanumeric(options) {
|
|
19
|
-
return validator('isAlphanumeric', (input, context, _this) => {
|
|
20
|
-
if (typeof input === 'string' && validatorJS.isAlphanumeric(input)) {
|
|
21
|
-
return input;
|
|
22
|
-
}
|
|
23
|
-
context.fail(_this, `"Value must be an alphanumeric string`, input);
|
|
24
|
-
}, options);
|
|
25
|
-
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { type ValidationOptions } from '../../core/index.js';
|
|
2
|
+
/**
|
|
3
|
+
* Check if the string contains only letters and numbers.
|
|
4
|
+
* @validator isAlphanumeric
|
|
5
|
+
*/
|
|
6
|
+
export declare function isAlphanumeric(options?: isAlphanumeric.Options): import("../../core/validator.js").Validator<string, string, import("../../core/types.js").ExecutionOptions>;
|
|
7
|
+
export declare namespace isAlphanumeric {
|
|
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
|
+
* Check if the string contains only letters and numbers.
|
|
5
|
+
* @validator isAlphanumeric
|
|
6
|
+
*/
|
|
7
|
+
export function isAlphanumeric(options) {
|
|
8
|
+
return validator('isAlphanumeric', (input, context, _this) => {
|
|
9
|
+
if (typeof input === 'string' && validatorJS.isAlphanumeric(input)) {
|
|
10
|
+
return input;
|
|
11
|
+
}
|
|
12
|
+
context.fail(_this, `"Value must be an alphanumeric string`, input);
|
|
13
|
+
}, options);
|
|
14
|
+
}
|
|
@@ -3,4 +3,8 @@ import { type ValidationOptions } from '../../core/index.js';
|
|
|
3
3
|
* Check if the string contains ASCII chars only.
|
|
4
4
|
* @validator isAscii
|
|
5
5
|
*/
|
|
6
|
-
export declare function isAscii(options?:
|
|
6
|
+
export declare function isAscii(options?: isAscii.Options): import("../../core/validator.js").Validator<string, string, import("../../core/types.js").ExecutionOptions>;
|
|
7
|
+
export declare namespace isAscii {
|
|
8
|
+
interface Options extends ValidationOptions {
|
|
9
|
+
}
|
|
10
|
+
}
|
|
@@ -1,9 +1,11 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { type IsBase64Options as _IsBase64Options } from '@browsery/validator';
|
|
2
2
|
import { type ValidationOptions } from '../../core/index.js';
|
|
3
|
-
export interface Base64ValidatorOptions extends ValidationOptions, validatorJS.IsBase64Options {
|
|
4
|
-
}
|
|
5
3
|
/**
|
|
6
4
|
* Validates if value is a "Base64" string.
|
|
7
5
|
* @validator isBase64
|
|
8
6
|
*/
|
|
9
|
-
export declare function isBase64(options?:
|
|
7
|
+
export declare function isBase64(options?: isBase64.Options): import("../../core/validator.js").Validator<string, string, import("../../core/types.js").ExecutionOptions>;
|
|
8
|
+
export declare namespace isBase64 {
|
|
9
|
+
interface Options extends ValidationOptions, _IsBase64Options {
|
|
10
|
+
}
|
|
11
|
+
}
|
|
@@ -3,4 +3,8 @@ import { type ValidationOptions } from '../../core/index.js';
|
|
|
3
3
|
* Validates if value is a BTC address.
|
|
4
4
|
* @validator isBtcAddress
|
|
5
5
|
*/
|
|
6
|
-
export declare function isBtcAddress(options?:
|
|
6
|
+
export declare function isBtcAddress(options?: isBtcAddress.Options): import("../../core/validator.js").Validator<string, string, import("../../core/types.js").ExecutionOptions>;
|
|
7
|
+
export declare namespace isBtcAddress {
|
|
8
|
+
interface Options extends ValidationOptions {
|
|
9
|
+
}
|
|
10
|
+
}
|
|
@@ -1,9 +1,11 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { type IsCreditCardOptions as _IsCreditCardOptions } from '@browsery/validator';
|
|
2
2
|
import { type ValidationOptions } from '../../core/index.js';
|
|
3
|
-
export interface CreditCardValidatorOptions extends ValidationOptions, validatorJS.IsCreditCardOptions {
|
|
4
|
-
}
|
|
5
3
|
/**
|
|
6
4
|
* Validates if value is a credit card number
|
|
7
5
|
* @validator isCreditCard
|
|
8
6
|
*/
|
|
9
|
-
export declare function isCreditCard(options?:
|
|
7
|
+
export declare function isCreditCard(options?: isCreditCard.Options): import("../../core/validator.js").Validator<string, string, import("../../core/types.js").ExecutionOptions>;
|
|
8
|
+
export declare namespace isCreditCard {
|
|
9
|
+
interface Options extends ValidationOptions, _IsCreditCardOptions {
|
|
10
|
+
}
|
|
11
|
+
}
|
|
@@ -4,4 +4,8 @@ import { type ValidationOptions } from '../../core/index.js';
|
|
|
4
4
|
* such as `0.1`, `.3`, `1.1`, `1.00003`, `4.0` etc.
|
|
5
5
|
* @validator isDecimal
|
|
6
6
|
*/
|
|
7
|
-
export declare function isDecimal(options?:
|
|
7
|
+
export declare function isDecimal(options?: isDecimal.Options): import("../../core/validator.js").Validator<string, string, import("../../core/types.js").ExecutionOptions>;
|
|
8
|
+
export declare namespace isDecimal {
|
|
9
|
+
interface Options extends ValidationOptions {
|
|
10
|
+
}
|
|
11
|
+
}
|
|
@@ -3,4 +3,8 @@ import { type ValidationOptions } from '../../core/index.js';
|
|
|
3
3
|
* Validates if value is an EAN (European Article Number)
|
|
4
4
|
* @validator isEAN
|
|
5
5
|
*/
|
|
6
|
-
export declare function isEAN(options?:
|
|
6
|
+
export declare function isEAN(options?: isEAN.Options): import("../../core/validator.js").Validator<string, string, import("../../core/types.js").ExecutionOptions>;
|
|
7
|
+
export declare namespace isEAN {
|
|
8
|
+
interface Options extends ValidationOptions {
|
|
9
|
+
}
|
|
10
|
+
}
|
|
@@ -1,62 +1,64 @@
|
|
|
1
1
|
import { type ValidationOptions } from '../../core/index.js';
|
|
2
|
-
export interface IsEmailOptions extends ValidationOptions {
|
|
3
|
-
/**
|
|
4
|
-
* If set to `true`, the validator will also match `Display Name <email-address>`.
|
|
5
|
-
*
|
|
6
|
-
* @default false
|
|
7
|
-
*/
|
|
8
|
-
allowDisplayName?: boolean;
|
|
9
|
-
/**
|
|
10
|
-
* If set to `true`, the validator will reject strings without the format `Display Name <email-address>`.
|
|
11
|
-
*
|
|
12
|
-
* @default false
|
|
13
|
-
*/
|
|
14
|
-
requireDisplayName?: boolean;
|
|
15
|
-
/**
|
|
16
|
-
* If set to `false`, the validator will not allow any non-English UTF8 character in email address' local part.
|
|
17
|
-
*
|
|
18
|
-
* @default true
|
|
19
|
-
*/
|
|
20
|
-
utf8LocalPart?: boolean;
|
|
21
|
-
/**
|
|
22
|
-
* If set to `true`, the validator will not check for the standard max length of an email.
|
|
23
|
-
*
|
|
24
|
-
* @default false
|
|
25
|
-
*/
|
|
26
|
-
ignoreMaxLength?: boolean;
|
|
27
|
-
/**
|
|
28
|
-
* If set to `true`, the validator will allow IP addresses in the host part.
|
|
29
|
-
*
|
|
30
|
-
* @default false
|
|
31
|
-
*/
|
|
32
|
-
allowIpDomain?: boolean;
|
|
33
|
-
/**
|
|
34
|
-
* If set to `true`, some additional validation will be enabled,
|
|
35
|
-
* e.g. disallowing certain syntactically valid email addresses that are rejected by GMail.
|
|
36
|
-
*
|
|
37
|
-
* @default false
|
|
38
|
-
*/
|
|
39
|
-
domainSpecificValidation?: boolean;
|
|
40
|
-
/**
|
|
41
|
-
* If set to an array of strings and the part of the email after
|
|
42
|
-
* the @ symbol matches one of the strings defined in it,
|
|
43
|
-
* the validation fails.
|
|
44
|
-
*/
|
|
45
|
-
hostBlacklist?: string[];
|
|
46
|
-
/**
|
|
47
|
-
* If set to an array of strings and the part of the email after
|
|
48
|
-
* the @ symbol matches none of the strings defined in it,
|
|
49
|
-
* the validation fails.
|
|
50
|
-
*/
|
|
51
|
-
hostWhitelist?: string[];
|
|
52
|
-
/**
|
|
53
|
-
* If set to a string, then the validator will reject emails that include
|
|
54
|
-
* any of the characters in the string, in the name part.
|
|
55
|
-
*/
|
|
56
|
-
blacklistedChars?: string;
|
|
57
|
-
}
|
|
58
2
|
/**
|
|
59
3
|
* Validates if value is a valid Email
|
|
60
4
|
* @validator isEmail
|
|
61
5
|
*/
|
|
62
|
-
export declare function isEmail(options?:
|
|
6
|
+
export declare function isEmail(options?: isEmail.Options): import("../../core/validator.js").Validator<string, string, import("../../core/types.js").ExecutionOptions>;
|
|
7
|
+
export declare namespace isEmail {
|
|
8
|
+
interface Options extends ValidationOptions {
|
|
9
|
+
/**
|
|
10
|
+
* If set to `true`, the validator will also match `Display Name <email-address>`.
|
|
11
|
+
*
|
|
12
|
+
* @default false
|
|
13
|
+
*/
|
|
14
|
+
allowDisplayName?: boolean;
|
|
15
|
+
/**
|
|
16
|
+
* If set to `true`, the validator will reject strings without the format `Display Name <email-address>`.
|
|
17
|
+
*
|
|
18
|
+
* @default false
|
|
19
|
+
*/
|
|
20
|
+
requireDisplayName?: boolean;
|
|
21
|
+
/**
|
|
22
|
+
* If set to `false`, the validator will not allow any non-English UTF8 character in email address' local part.
|
|
23
|
+
*
|
|
24
|
+
* @default true
|
|
25
|
+
*/
|
|
26
|
+
utf8LocalPart?: boolean;
|
|
27
|
+
/**
|
|
28
|
+
* If set to `true`, the validator will not check for the standard max length of an email.
|
|
29
|
+
*
|
|
30
|
+
* @default false
|
|
31
|
+
*/
|
|
32
|
+
ignoreMaxLength?: boolean;
|
|
33
|
+
/**
|
|
34
|
+
* If set to `true`, the validator will allow IP addresses in the host part.
|
|
35
|
+
*
|
|
36
|
+
* @default false
|
|
37
|
+
*/
|
|
38
|
+
allowIpDomain?: boolean;
|
|
39
|
+
/**
|
|
40
|
+
* If set to `true`, some additional validation will be enabled,
|
|
41
|
+
* e.g. disallowing certain syntactically valid email addresses that are rejected by GMail.
|
|
42
|
+
*
|
|
43
|
+
* @default false
|
|
44
|
+
*/
|
|
45
|
+
domainSpecificValidation?: boolean;
|
|
46
|
+
/**
|
|
47
|
+
* If set to an array of strings and the part of the email after
|
|
48
|
+
* the @ symbol matches one of the strings defined in it,
|
|
49
|
+
* the validation fails.
|
|
50
|
+
*/
|
|
51
|
+
hostBlacklist?: string[];
|
|
52
|
+
/**
|
|
53
|
+
* If set to an array of strings and the part of the email after
|
|
54
|
+
* the @ symbol matches none of the strings defined in it,
|
|
55
|
+
* the validation fails.
|
|
56
|
+
*/
|
|
57
|
+
hostWhitelist?: string[];
|
|
58
|
+
/**
|
|
59
|
+
* If set to a string, then the validator will reject emails that include
|
|
60
|
+
* any of the characters in the string, in the name part.
|
|
61
|
+
*/
|
|
62
|
+
blacklistedChars?: string;
|
|
63
|
+
}
|
|
64
|
+
}
|
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
import { type ValidationOptions } from '../../core/index.js';
|
|
2
2
|
/**
|
|
3
|
-
* Validates if value is
|
|
3
|
+
* Validates if value is an ETH (Ethereum) address.
|
|
4
4
|
* @validator isETHAddress
|
|
5
5
|
*/
|
|
6
|
-
export declare function isETHAddress(options?:
|
|
6
|
+
export declare function isETHAddress(options?: isETHAddress.Options): import("../../core/validator.js").Validator<string, string, import("../../core/types.js").ExecutionOptions>;
|
|
7
|
+
export declare namespace isETHAddress {
|
|
8
|
+
interface Options extends ValidationOptions {
|
|
9
|
+
}
|
|
10
|
+
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import validatorJS from '@browsery/validator';
|
|
2
2
|
import { validator, } from '../../core/index.js';
|
|
3
3
|
/**
|
|
4
|
-
* Validates if value is
|
|
4
|
+
* Validates if value is an ETH (Ethereum) address.
|
|
5
5
|
* @validator isETHAddress
|
|
6
6
|
*/
|
|
7
7
|
export function isETHAddress(options) {
|
|
@@ -1,13 +1,15 @@
|
|
|
1
1
|
import { type ValidationOptions } from '../../core/index.js';
|
|
2
|
-
export interface IsFQDNOptions extends ValidationOptions {
|
|
3
|
-
/**
|
|
4
|
-
* If set to true, the validator will allow domain starting with `*.` (e.g. `*.example.com` or `*.shop.example.com`).
|
|
5
|
-
* @default false
|
|
6
|
-
*/
|
|
7
|
-
allowWildcard?: boolean;
|
|
8
|
-
}
|
|
9
2
|
/**
|
|
10
3
|
* Validates if value is an FQDN
|
|
11
4
|
* @validator isFQDN
|
|
12
5
|
*/
|
|
13
|
-
export declare function isFQDN(options?:
|
|
6
|
+
export declare function isFQDN(options?: isFQDN.Options): import("../../core/validator.js").Validator<string, string, import("../../core/types.js").ExecutionOptions>;
|
|
7
|
+
export declare namespace isFQDN {
|
|
8
|
+
interface Options extends ValidationOptions {
|
|
9
|
+
/**
|
|
10
|
+
* If set to true, the validator will allow domain starting with `*.` (e.g. `*.example.com` or `*.shop.example.com`).
|
|
11
|
+
* @default false
|
|
12
|
+
*/
|
|
13
|
+
allowWildcard?: boolean;
|
|
14
|
+
}
|
|
15
|
+
}
|
|
@@ -1,8 +1,10 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { type HashAlgorithm as _HashAlgorithm } from '@browsery/validator';
|
|
2
2
|
import { type ValidationOptions } from '../../core/index.js';
|
|
3
|
-
export type HashAlgorithm = validatorJS.HashAlgorithm;
|
|
4
3
|
/**
|
|
5
4
|
* Validates if value a hash of type algorithm
|
|
6
5
|
* @validator isHash
|
|
7
6
|
*/
|
|
8
|
-
export declare function isHash(algorithm: HashAlgorithm, options?: ValidationOptions): import("../../core/validator.js").Validator<string, string, import("../../core/types.js").ExecutionOptions>;
|
|
7
|
+
export declare function isHash(algorithm: isHash.HashAlgorithm, options?: ValidationOptions): import("../../core/validator.js").Validator<string, string, import("../../core/types.js").ExecutionOptions>;
|
|
8
|
+
export declare namespace isHash {
|
|
9
|
+
type HashAlgorithm = _HashAlgorithm;
|
|
10
|
+
}
|
|
@@ -3,4 +3,8 @@ import { type ValidationOptions } from '../../core/index.js';
|
|
|
3
3
|
* Validates if value is a Hex Color
|
|
4
4
|
* @validator isHexColor
|
|
5
5
|
*/
|
|
6
|
-
export declare function isHexColor(options?:
|
|
6
|
+
export declare function isHexColor(options?: isHexColor.Options): import("../../core/validator.js").Validator<string, string, import("../../core/types.js").ExecutionOptions>;
|
|
7
|
+
export declare namespace isHexColor {
|
|
8
|
+
interface Options extends ValidationOptions {
|
|
9
|
+
}
|
|
10
|
+
}
|
|
@@ -3,4 +3,8 @@ import { type ValidationOptions } from '../../core/index.js';
|
|
|
3
3
|
* Check if the string is a hexadecimal number.
|
|
4
4
|
* @validator isHex
|
|
5
5
|
*/
|
|
6
|
-
export declare function isHex(options?:
|
|
6
|
+
export declare function isHex(options?: isHex.Options): import("../../core/validator.js").Validator<string, string, import("../../core/types.js").ExecutionOptions>;
|
|
7
|
+
export declare namespace isHex {
|
|
8
|
+
interface Options extends ValidationOptions {
|
|
9
|
+
}
|
|
10
|
+
}
|
|
@@ -3,9 +3,8 @@ import { type ValidationOptions } from '../../core/index.js';
|
|
|
3
3
|
* Validates if value is an IBAN (International Bank Account Number)
|
|
4
4
|
* @validator isIBAN
|
|
5
5
|
*/
|
|
6
|
-
export declare function isIBAN(options?:
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
export declare function isSWIFT(options?: ValidationOptions): import("../../core/validator.js").Validator<string, string, import("../../core/types.js").ExecutionOptions>;
|
|
6
|
+
export declare function isIBAN(options?: isIBAN.Options): import("../../core/validator.js").Validator<string, string, import("../../core/types.js").ExecutionOptions>;
|
|
7
|
+
export declare namespace isIBAN {
|
|
8
|
+
interface Options extends ValidationOptions {
|
|
9
|
+
}
|
|
10
|
+
}
|
|
@@ -11,14 +11,3 @@ export function isIBAN(options) {
|
|
|
11
11
|
context.fail(_this, `Value must be a valid IBAN (International Bank Account Number)`, input);
|
|
12
12
|
}, options);
|
|
13
13
|
}
|
|
14
|
-
/**
|
|
15
|
-
* Validates if value is a BIC (Bank Identification Code) or SWIFT code
|
|
16
|
-
* @validator isSWIFT
|
|
17
|
-
*/
|
|
18
|
-
export function isSWIFT(options) {
|
|
19
|
-
return validator('isSWIFT', (input, context, _this) => {
|
|
20
|
-
if (typeof input === 'string' && validatorJS.isBIC(input))
|
|
21
|
-
return input;
|
|
22
|
-
context.fail(_this, `Value must be a valid a BIC (Bank Identification Code) or SWIFT code`, input);
|
|
23
|
-
}, options);
|
|
24
|
-
}
|
|
@@ -1,11 +1,18 @@
|
|
|
1
|
+
import { type IPVersion as _IPVersion } from '@browsery/validator';
|
|
1
2
|
import { type ValidationOptions } from '../../core/index.js';
|
|
2
3
|
/**
|
|
3
4
|
* Validates if value is an IP
|
|
4
5
|
* @validator isIP
|
|
5
6
|
*/
|
|
6
|
-
export declare function isIP(version?:
|
|
7
|
+
export declare function isIP(version?: isIP.IPVersion, options?: ValidationOptions): import("../../core/validator.js").Validator<string, string, import("../../core/types.js").ExecutionOptions>;
|
|
7
8
|
/**
|
|
8
9
|
* Validates if value is an IP
|
|
9
10
|
* @validator isIPRange
|
|
10
11
|
*/
|
|
11
|
-
export declare function isIPRange(version?:
|
|
12
|
+
export declare function isIPRange(version?: isIPRange.IPVersion, options?: ValidationOptions): import("../../core/validator.js").Validator<string, string, import("../../core/types.js").ExecutionOptions>;
|
|
13
|
+
export declare namespace isIP {
|
|
14
|
+
type IPVersion = _IPVersion;
|
|
15
|
+
}
|
|
16
|
+
export declare namespace isIPRange {
|
|
17
|
+
type IPVersion = _IPVersion;
|
|
18
|
+
}
|
|
@@ -1,14 +1,16 @@
|
|
|
1
1
|
import { type ValidationOptions } from '../../core/index.js';
|
|
2
|
-
export interface IsISSNOptions extends ValidationOptions {
|
|
3
|
-
/**
|
|
4
|
-
* If set to `true`, ISSNs with a lowercase `x` as the check digit are rejected.
|
|
5
|
-
*
|
|
6
|
-
* @default false
|
|
7
|
-
*/
|
|
8
|
-
caseSensitive?: boolean;
|
|
9
|
-
}
|
|
10
2
|
/**
|
|
11
3
|
* Validates if value is an ISSN
|
|
12
4
|
* @validator isISSN
|
|
13
5
|
*/
|
|
14
|
-
export declare function isISSN(options?:
|
|
6
|
+
export declare function isISSN(options?: isISSN.Options): import("../../core/validator.js").Validator<string, string, import("../../core/types.js").ExecutionOptions>;
|
|
7
|
+
export declare namespace isISSN {
|
|
8
|
+
interface Options extends ValidationOptions {
|
|
9
|
+
/**
|
|
10
|
+
* If set to `true`, ISSNs with a lowercase `x` as the check digit are rejected.
|
|
11
|
+
*
|
|
12
|
+
* @default false
|
|
13
|
+
*/
|
|
14
|
+
caseSensitive?: boolean;
|
|
15
|
+
}
|
|
16
|
+
}
|
|
@@ -3,4 +3,8 @@ import { type ValidationOptions } from '../../core/index.js';
|
|
|
3
3
|
* Validates if value a valid JWT token
|
|
4
4
|
* @validator isJWT
|
|
5
5
|
*/
|
|
6
|
-
export declare function isJWT(options?:
|
|
6
|
+
export declare function isJWT(options?: isJWT.Options): import("../../core/validator.js").Validator<string, string, import("../../core/types.js").ExecutionOptions>;
|
|
7
|
+
export declare namespace isJWT {
|
|
8
|
+
interface Options extends ValidationOptions {
|
|
9
|
+
}
|
|
10
|
+
}
|
|
@@ -3,9 +3,8 @@ import { type ValidationOptions } from '../../core/index.js';
|
|
|
3
3
|
* Validates if value a Lowercase string
|
|
4
4
|
* @validator isLowercase
|
|
5
5
|
*/
|
|
6
|
-
export declare function isLowercase(options?:
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
export declare function isUppercase(options?: ValidationOptions): import("../../core/validator.js").Validator<string, string, import("../../core/types.js").ExecutionOptions>;
|
|
6
|
+
export declare function isLowercase(options?: isLowercase.Options): import("../../core/validator.js").Validator<string, string, import("../../core/types.js").ExecutionOptions>;
|
|
7
|
+
export declare namespace isLowercase {
|
|
8
|
+
interface Options extends ValidationOptions {
|
|
9
|
+
}
|
|
10
|
+
}
|
|
@@ -12,15 +12,3 @@ export function isLowercase(options) {
|
|
|
12
12
|
context.fail(_this, `Value must be a lowercase string`, input);
|
|
13
13
|
}, options);
|
|
14
14
|
}
|
|
15
|
-
/**
|
|
16
|
-
* Validates if value a Uppercase string
|
|
17
|
-
* @validator isUppercase
|
|
18
|
-
*/
|
|
19
|
-
export function isUppercase(options) {
|
|
20
|
-
return validator('isUppercase', (input, context, _this) => {
|
|
21
|
-
if (typeof input === 'string' && validatorJS.isUppercase(input)) {
|
|
22
|
-
return input;
|
|
23
|
-
}
|
|
24
|
-
context.fail(_this, `Value must be an uppercase string`, input);
|
|
25
|
-
}, options);
|
|
26
|
-
}
|
|
@@ -1,21 +1,23 @@
|
|
|
1
1
|
import { type ValidationOptions } from '../../core/index.js';
|
|
2
|
-
export interface IsMACAddressOptions extends ValidationOptions {
|
|
3
|
-
/**
|
|
4
|
-
* If set to `true`, the validator will allow MAC addresses without the colons.
|
|
5
|
-
* Also, it allows the use of hyphens or spaces.
|
|
6
|
-
*
|
|
7
|
-
* e.g. `01 02 03 04 05 ab` or `01-02-03-04-05-ab`.
|
|
8
|
-
*
|
|
9
|
-
* @default false
|
|
10
|
-
*/
|
|
11
|
-
noSeparators?: boolean;
|
|
12
|
-
/**
|
|
13
|
-
* Setting `eui` allows for validation against EUI-48 or EUI-64 instead of both.
|
|
14
|
-
*/
|
|
15
|
-
eui?: '48' | '64';
|
|
16
|
-
}
|
|
17
2
|
/**
|
|
18
3
|
* Validates if value is an MACAddress
|
|
19
4
|
* @validator isMACAddress
|
|
20
5
|
*/
|
|
21
|
-
export declare function isMACAddress(options?:
|
|
6
|
+
export declare function isMACAddress(options?: isMACAddress.Options): import("../../core/validator.js").Validator<string, string, import("../../core/types.js").ExecutionOptions>;
|
|
7
|
+
export declare namespace isMACAddress {
|
|
8
|
+
interface Options extends ValidationOptions {
|
|
9
|
+
/**
|
|
10
|
+
* If set to `true`, the validator will allow MAC addresses without the colons.
|
|
11
|
+
* Also, it allows the use of hyphens or spaces.
|
|
12
|
+
*
|
|
13
|
+
* e.g. `01 02 03 04 05 ab` or `01-02-03-04-05-ab`.
|
|
14
|
+
*
|
|
15
|
+
* @default false
|
|
16
|
+
*/
|
|
17
|
+
noSeparators?: boolean;
|
|
18
|
+
/**
|
|
19
|
+
* Setting `eui` allows for validation against EUI-48 or EUI-64 instead of both.
|
|
20
|
+
*/
|
|
21
|
+
eui?: '48' | '64';
|
|
22
|
+
}
|
|
23
|
+
}
|