valgen 7.0.1 → 7.0.3
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/README.md +1 -1
- package/constants.js +1 -1
- package/core/constants.d.ts +11 -0
- package/core/constants.js +11 -0
- package/core/context.d.ts +57 -0
- package/core/context.js +57 -0
- package/core/types.d.ts +40 -0
- package/core/utilities.d.ts +42 -2
- package/core/utilities.js +21 -1
- package/core/validation-error.d.ts +13 -0
- package/core/validation-error.js +13 -0
- package/core/validator.d.ts +100 -0
- package/core/validator.js +6 -0
- package/package.json +1 -1
- package/rules/format-rules/is-alpha.d.ts +10 -1
- package/rules/format-rules/is-alpha.js +10 -1
- package/rules/format-rules/is-alphanumeric.d.ts +10 -1
- package/rules/format-rules/is-alphanumeric.js +10 -1
- package/rules/format-rules/is-ascii.d.ts +10 -1
- package/rules/format-rules/is-ascii.js +10 -1
- package/rules/format-rules/is-base64.d.ts +20 -1
- package/rules/format-rules/is-base64.js +10 -1
- package/rules/format-rules/is-btc-address.d.ts +10 -1
- package/rules/format-rules/is-btc-address.js +10 -1
- package/rules/format-rules/is-credit-card.d.ts +16 -1
- package/rules/format-rules/is-credit-card.js +11 -1
- package/rules/format-rules/is-decimal.d.ts +12 -2
- package/rules/format-rules/is-decimal.js +12 -2
- package/rules/format-rules/is-ean.d.ts +11 -1
- package/rules/format-rules/is-ean.js +11 -1
- package/rules/format-rules/is-email.d.ts +19 -7
- package/rules/format-rules/is-email.js +13 -1
- package/rules/format-rules/is-eth-address.d.ts +10 -1
- package/rules/format-rules/is-eth-address.js +10 -1
- package/rules/format-rules/is-fqdn.d.ts +13 -2
- package/rules/format-rules/is-fqdn.js +12 -1
- package/rules/format-rules/is-hash.d.ts +17 -1
- package/rules/format-rules/is-hash.js +16 -1
- package/rules/format-rules/is-hex-color.d.ts +13 -1
- package/rules/format-rules/is-hex-color.js +13 -1
- package/rules/format-rules/is-hex.d.ts +13 -1
- package/rules/format-rules/is-hex.js +13 -1
- package/rules/format-rules/is-iban.d.ts +33 -2
- package/rules/format-rules/is-iban.js +19 -1
- package/rules/format-rules/is-ip.d.ts +44 -2
- package/rules/format-rules/is-ip.js +42 -2
- package/rules/format-rules/is-issn.d.ts +19 -2
- package/rules/format-rules/is-issn.js +18 -1
- package/rules/format-rules/is-jwt.d.ts +16 -1
- package/rules/format-rules/is-jwt.js +16 -1
- package/rules/format-rules/is-lowercase.d.ts +13 -1
- package/rules/format-rules/is-lowercase.js +13 -1
- package/rules/format-rules/is-mac-address.d.ts +19 -2
- package/rules/format-rules/is-mac-address.js +16 -1
- package/rules/format-rules/is-mobile-phone.d.ts +19 -3
- package/rules/format-rules/is-mobile-phone.js +17 -1
- package/rules/format-rules/is-object-id.d.ts +20 -1
- package/rules/format-rules/is-object-id.js +19 -1
- package/rules/format-rules/is-passport-number.d.ts +17 -1
- package/rules/format-rules/is-passport-number.js +17 -1
- package/rules/format-rules/is-port.d.ts +16 -1
- package/rules/format-rules/is-port.js +16 -1
- package/rules/format-rules/is-swift.d.ts +15 -1
- package/rules/format-rules/is-swift.js +15 -1
- package/rules/format-rules/is-time.d.ts +22 -1
- package/rules/format-rules/is-time.js +22 -1
- package/rules/format-rules/is-uppercase.d.ts +15 -1
- package/rules/format-rules/is-uppercase.js +15 -1
- package/rules/format-rules/is-url.d.ts +99 -1
- package/rules/format-rules/is-url.js +19 -1
- package/rules/format-rules/is-uuid.d.ts +23 -1
- package/rules/format-rules/is-uuid.js +23 -1
- package/rules/format-rules/is-vat-number.d.ts +19 -2
- package/rules/format-rules/is-vat-number.js +19 -2
- package/rules/format-rules/matches.d.ts +27 -1
- package/rules/format-rules/matches.js +23 -1
- package/rules/logical-rules/is-defined.d.ts +14 -2
- package/rules/logical-rules/is-defined.js +13 -2
- package/rules/logical-rules/is-empty.d.ts +40 -2
- package/rules/logical-rules/is-empty.js +38 -2
- package/rules/logical-rules/is-equal.d.ts +31 -4
- package/rules/logical-rules/is-equal.js +29 -4
- package/rules/logical-rules/is-gt.d.ts +26 -1
- package/rules/logical-rules/is-gt.js +20 -1
- package/rules/logical-rules/is-gte.d.ts +25 -1
- package/rules/logical-rules/is-gte.js +20 -1
- package/rules/logical-rules/is-lt.d.ts +24 -1
- package/rules/logical-rules/is-lt.js +19 -1
- package/rules/logical-rules/is-lte.d.ts +25 -1
- package/rules/logical-rules/is-lte.js +20 -1
- package/rules/logical-rules/length.d.ts +38 -2
- package/rules/logical-rules/length.js +38 -2
- package/rules/logical-rules/range.d.ts +25 -1
- package/rules/logical-rules/range.js +23 -1
- package/rules/type-rules/is-any.d.ts +12 -1
- package/rules/type-rules/is-any.js +12 -1
- package/rules/type-rules/is-array.d.ts +23 -2
- package/rules/type-rules/is-array.js +23 -2
- package/rules/type-rules/is-bigint.d.ts +14 -2
- package/rules/type-rules/is-bigint.js +14 -2
- package/rules/type-rules/is-boolean.d.ts +17 -2
- package/rules/type-rules/is-boolean.js +17 -2
- package/rules/type-rules/is-date.d.ts +47 -5
- package/rules/type-rules/is-date.js +42 -5
- package/rules/type-rules/is-enum.d.ts +23 -1
- package/rules/type-rules/is-enum.js +21 -1
- package/rules/type-rules/is-instanceof.d.ts +21 -1
- package/rules/type-rules/is-instanceof.js +21 -1
- package/rules/type-rules/is-integer.d.ts +17 -2
- package/rules/type-rules/is-integer.js +17 -2
- package/rules/type-rules/is-null.d.ts +51 -4
- package/rules/type-rules/is-null.js +51 -4
- package/rules/type-rules/is-number.d.ts +17 -2
- package/rules/type-rules/is-number.js +17 -2
- package/rules/type-rules/is-object.d.ts +45 -7
- package/rules/type-rules/is-object.js +40 -7
- package/rules/type-rules/is-record.d.ts +21 -2
- package/rules/type-rules/is-record.js +21 -2
- package/rules/type-rules/is-string.d.ts +16 -2
- package/rules/type-rules/is-string.js +16 -2
- package/rules/type-rules/is-tuple.d.ts +21 -2
- package/rules/type-rules/is-undefined.d.ts +16 -4
- package/rules/type-rules/is-undefined.js +16 -4
- package/rules/utility-rules/all-of.d.ts +28 -1
- package/rules/utility-rules/all-of.js +27 -1
- package/rules/utility-rules/exists.d.ts +30 -1
- package/rules/utility-rules/exists.js +29 -1
- package/rules/utility-rules/fixed.d.ts +19 -1
- package/rules/utility-rules/fixed.js +19 -1
- package/rules/utility-rules/get-length.d.ts +25 -2
- package/rules/utility-rules/get-length.js +25 -2
- package/rules/utility-rules/nullable.d.ts +28 -1
- package/rules/utility-rules/nullable.js +27 -1
- package/rules/utility-rules/one-of.d.ts +52 -3
- package/rules/utility-rules/one-of.js +51 -3
- package/rules/utility-rules/optional.d.ts +29 -1
- package/rules/utility-rules/optional.js +28 -1
- package/rules/utility-rules/pipe.d.ts +38 -1
- package/rules/utility-rules/pipe.js +30 -1
- package/rules/utility-rules/required.d.ts +39 -1
- package/rules/utility-rules/required.js +32 -1
- package/rules/utility-rules/string-utils.d.ts +99 -5
- package/rules/utility-rules/string-utils.js +53 -3
|
@@ -1,11 +1,30 @@
|
|
|
1
1
|
import { type IsBase64Options as _IsBase64Options } from '@browsery/validator';
|
|
2
2
|
import { type ValidationOptions } from '../../core/index.js';
|
|
3
3
|
/**
|
|
4
|
-
* Validates
|
|
4
|
+
* Validates that a string is Base64-encoded. Delegates to
|
|
5
|
+
* `validatorJS.isBase64(input, options)`.
|
|
5
6
|
* @validator isBase64
|
|
7
|
+
* @param options - Validation options.
|
|
8
|
+
* @returns The input string, unchanged, if valid.
|
|
9
|
+
* @throws if `input` is not a valid Base64 string: `Value must be a Base64 string`
|
|
10
|
+
* @example
|
|
11
|
+
* ```ts
|
|
12
|
+
* isBase64('SGVsbG8gV29ybGQ='); // => 'SGVsbG8gV29ybGQ='
|
|
13
|
+
* isBase64('not-base64!!'); // throws ValidationError: "Value must be a Base64 string"
|
|
14
|
+
* ```
|
|
6
15
|
*/
|
|
7
16
|
export declare function isBase64(options?: isBase64.Options): import("../../core/validator.js").Validator<string, string, import("../../core/types.js").ExecutionOptions>;
|
|
8
17
|
export declare namespace isBase64 {
|
|
9
18
|
interface Options extends ValidationOptions, _IsBase64Options {
|
|
19
|
+
/**
|
|
20
|
+
* If `true`, expects URL-safe Base64 (`-`/`_` instead of `+`/`/`).
|
|
21
|
+
* @defaultValue false
|
|
22
|
+
*/
|
|
23
|
+
urlSafe?: boolean;
|
|
24
|
+
/**
|
|
25
|
+
* Whether trailing `=` padding is required.
|
|
26
|
+
* @defaultValue !urlSafe
|
|
27
|
+
*/
|
|
28
|
+
padding?: boolean;
|
|
10
29
|
}
|
|
11
30
|
}
|
|
@@ -1,8 +1,17 @@
|
|
|
1
1
|
import validatorJS, {} from '@browsery/validator';
|
|
2
2
|
import { validator, } from '../../core/index.js';
|
|
3
3
|
/**
|
|
4
|
-
* Validates
|
|
4
|
+
* Validates that a string is Base64-encoded. Delegates to
|
|
5
|
+
* `validatorJS.isBase64(input, options)`.
|
|
5
6
|
* @validator isBase64
|
|
7
|
+
* @param options - Validation options.
|
|
8
|
+
* @returns The input string, unchanged, if valid.
|
|
9
|
+
* @throws if `input` is not a valid Base64 string: `Value must be a Base64 string`
|
|
10
|
+
* @example
|
|
11
|
+
* ```ts
|
|
12
|
+
* isBase64('SGVsbG8gV29ybGQ='); // => 'SGVsbG8gV29ybGQ='
|
|
13
|
+
* isBase64('not-base64!!'); // throws ValidationError: "Value must be a Base64 string"
|
|
14
|
+
* ```
|
|
6
15
|
*/
|
|
7
16
|
export function isBase64(options) {
|
|
8
17
|
return validator(isBase64.name, (input, context, _this) => {
|
|
@@ -1,7 +1,16 @@
|
|
|
1
1
|
import { type ValidationOptions } from '../../core/index.js';
|
|
2
2
|
/**
|
|
3
|
-
* Validates
|
|
3
|
+
* Validates that a string is a valid Bitcoin (BTC) address. Delegates to
|
|
4
|
+
* `validatorJS.isBtcAddress`.
|
|
4
5
|
* @validator isBtcAddress
|
|
6
|
+
* @param options - Validation options.
|
|
7
|
+
* @returns The input string, unchanged, if valid.
|
|
8
|
+
* @throws if `input` is not a valid BTC address: `Value must be a valid BTC address`
|
|
9
|
+
* @example
|
|
10
|
+
* ```ts
|
|
11
|
+
* isBtcAddress('1BvBMSEYstWetqTFn5Au4m4GFg7xJaNVN2'); // => '1BvBMSEYstWetqTFn5Au4m4GFg7xJaNVN2'
|
|
12
|
+
* isBtcAddress('notabtcaddress'); // throws ValidationError: "Value must be a valid BTC address"
|
|
13
|
+
* ```
|
|
5
14
|
*/
|
|
6
15
|
export declare function isBtcAddress(options?: isBtcAddress.Options): import("../../core/validator.js").Validator<string, string, import("../../core/types.js").ExecutionOptions>;
|
|
7
16
|
export declare namespace isBtcAddress {
|
|
@@ -1,8 +1,17 @@
|
|
|
1
1
|
import validatorJS from '@browsery/validator';
|
|
2
2
|
import { validator, } from '../../core/index.js';
|
|
3
3
|
/**
|
|
4
|
-
* Validates
|
|
4
|
+
* Validates that a string is a valid Bitcoin (BTC) address. Delegates to
|
|
5
|
+
* `validatorJS.isBtcAddress`.
|
|
5
6
|
* @validator isBtcAddress
|
|
7
|
+
* @param options - Validation options.
|
|
8
|
+
* @returns The input string, unchanged, if valid.
|
|
9
|
+
* @throws if `input` is not a valid BTC address: `Value must be a valid BTC address`
|
|
10
|
+
* @example
|
|
11
|
+
* ```ts
|
|
12
|
+
* isBtcAddress('1BvBMSEYstWetqTFn5Au4m4GFg7xJaNVN2'); // => '1BvBMSEYstWetqTFn5Au4m4GFg7xJaNVN2'
|
|
13
|
+
* isBtcAddress('notabtcaddress'); // throws ValidationError: "Value must be a valid BTC address"
|
|
14
|
+
* ```
|
|
6
15
|
*/
|
|
7
16
|
export function isBtcAddress(options) {
|
|
8
17
|
return validator(isBtcAddress.name, (input, context, _this) => {
|
|
@@ -1,12 +1,27 @@
|
|
|
1
1
|
import { type IsCreditCardOptions as _IsCreditCardOptions } from '@browsery/validator';
|
|
2
2
|
import { type ValidationOptions } from '../../core/index.js';
|
|
3
3
|
/**
|
|
4
|
-
* Validates
|
|
4
|
+
* Validates that a string is a valid credit card number (Luhn checksum plus
|
|
5
|
+
* an optional provider-specific pattern). Delegates to
|
|
6
|
+
* `validatorJS.isCreditCard(input, options)`.
|
|
5
7
|
* @validator isCreditCard
|
|
8
|
+
* @param options - Validation options.
|
|
9
|
+
* @returns The input string, unchanged, if valid.
|
|
10
|
+
* @throws if `input` is not a valid credit card number: `Value must be a valid Credit Card number`
|
|
11
|
+
* @example
|
|
12
|
+
* ```ts
|
|
13
|
+
* isCreditCard('4111111111111111'); // => '4111111111111111'
|
|
14
|
+
* isCreditCard('4111111111111112'); // throws ValidationError: "Value must be a valid Credit Card number"
|
|
15
|
+
* ```
|
|
6
16
|
*/
|
|
7
17
|
export declare function isCreditCard(options?: isCreditCard.Options): import("../../core/validator.js").Validator<string, string, import("../../core/types.js").ExecutionOptions>;
|
|
8
18
|
export declare namespace isCreditCard {
|
|
9
19
|
interface Options extends ValidationOptions, _IsCreditCardOptions {
|
|
20
|
+
/**
|
|
21
|
+
* Restricts validation to a specific card provider/network.
|
|
22
|
+
* @defaultValue undefined
|
|
23
|
+
*/
|
|
24
|
+
provider?: Provider;
|
|
10
25
|
}
|
|
11
26
|
type Provider = _IsCreditCardOptions['provider'];
|
|
12
27
|
}
|
|
@@ -1,8 +1,18 @@
|
|
|
1
1
|
import validatorJS, {} from '@browsery/validator';
|
|
2
2
|
import { validator, } from '../../core/index.js';
|
|
3
3
|
/**
|
|
4
|
-
* Validates
|
|
4
|
+
* Validates that a string is a valid credit card number (Luhn checksum plus
|
|
5
|
+
* an optional provider-specific pattern). Delegates to
|
|
6
|
+
* `validatorJS.isCreditCard(input, options)`.
|
|
5
7
|
* @validator isCreditCard
|
|
8
|
+
* @param options - Validation options.
|
|
9
|
+
* @returns The input string, unchanged, if valid.
|
|
10
|
+
* @throws if `input` is not a valid credit card number: `Value must be a valid Credit Card number`
|
|
11
|
+
* @example
|
|
12
|
+
* ```ts
|
|
13
|
+
* isCreditCard('4111111111111111'); // => '4111111111111111'
|
|
14
|
+
* isCreditCard('4111111111111112'); // throws ValidationError: "Value must be a valid Credit Card number"
|
|
15
|
+
* ```
|
|
6
16
|
*/
|
|
7
17
|
export function isCreditCard(options) {
|
|
8
18
|
return validator(isCreditCard.name, (input, context, _this) => {
|
|
@@ -1,8 +1,18 @@
|
|
|
1
1
|
import { type ValidationOptions } from '../../core/index.js';
|
|
2
2
|
/**
|
|
3
|
-
*
|
|
4
|
-
*
|
|
3
|
+
* Validates that a string represents a decimal number, such as `0.1`, `.3`,
|
|
4
|
+
* `1.1`, `1.00003`, `4.0` etc. Delegates to `validatorJS.isDecimal(input)`
|
|
5
|
+
* with no options passed through, so it always uses the underlying
|
|
6
|
+
* library's default rules.
|
|
5
7
|
* @validator isDecimal
|
|
8
|
+
* @param options - Validation options.
|
|
9
|
+
* @returns The input string, unchanged, if valid.
|
|
10
|
+
* @throws if `input` is not a decimal number string: `Value must be a decimal number string`
|
|
11
|
+
* @example
|
|
12
|
+
* ```ts
|
|
13
|
+
* isDecimal('1.5'); // => '1.5'
|
|
14
|
+
* isDecimal('abc'); // throws ValidationError: "Value must be a decimal number string"
|
|
15
|
+
* ```
|
|
6
16
|
*/
|
|
7
17
|
export declare function isDecimal(options?: isDecimal.Options): import("../../core/validator.js").Validator<string, string, import("../../core/types.js").ExecutionOptions>;
|
|
8
18
|
export declare namespace isDecimal {
|
|
@@ -1,9 +1,19 @@
|
|
|
1
1
|
import validatorJS from '@browsery/validator';
|
|
2
2
|
import { validator, } from '../../core/index.js';
|
|
3
3
|
/**
|
|
4
|
-
*
|
|
5
|
-
*
|
|
4
|
+
* Validates that a string represents a decimal number, such as `0.1`, `.3`,
|
|
5
|
+
* `1.1`, `1.00003`, `4.0` etc. Delegates to `validatorJS.isDecimal(input)`
|
|
6
|
+
* with no options passed through, so it always uses the underlying
|
|
7
|
+
* library's default rules.
|
|
6
8
|
* @validator isDecimal
|
|
9
|
+
* @param options - Validation options.
|
|
10
|
+
* @returns The input string, unchanged, if valid.
|
|
11
|
+
* @throws if `input` is not a decimal number string: `Value must be a decimal number string`
|
|
12
|
+
* @example
|
|
13
|
+
* ```ts
|
|
14
|
+
* isDecimal('1.5'); // => '1.5'
|
|
15
|
+
* isDecimal('abc'); // throws ValidationError: "Value must be a decimal number string"
|
|
16
|
+
* ```
|
|
7
17
|
*/
|
|
8
18
|
export function isDecimal(options) {
|
|
9
19
|
return validator(isDecimal.name, (input, context, _this) => {
|
|
@@ -1,7 +1,17 @@
|
|
|
1
1
|
import { type ValidationOptions } from '../../core/index.js';
|
|
2
2
|
/**
|
|
3
|
-
* Validates
|
|
3
|
+
* Validates that a string is a valid EAN (European Article Number).
|
|
4
|
+
* Delegates to `validatorJS.isEAN(input)` (checksum-validated EAN-8/EAN-13
|
|
5
|
+
* style codes).
|
|
4
6
|
* @validator isEAN
|
|
7
|
+
* @param options - Validation options.
|
|
8
|
+
* @returns The input string, unchanged, if valid.
|
|
9
|
+
* @throws if `input` is not a valid EAN: `Value must be a valid EAN (European Article Number)`
|
|
10
|
+
* @example
|
|
11
|
+
* ```ts
|
|
12
|
+
* isEAN('4006381333931'); // => '4006381333931'
|
|
13
|
+
* isEAN('1234567890123'); // throws ValidationError: "Value must be a valid EAN (European Article Number)"
|
|
14
|
+
* ```
|
|
5
15
|
*/
|
|
6
16
|
export declare function isEAN(options?: isEAN.Options): import("../../core/validator.js").Validator<string, string, import("../../core/types.js").ExecutionOptions>;
|
|
7
17
|
export declare namespace isEAN {
|
|
@@ -1,8 +1,18 @@
|
|
|
1
1
|
import validatorJS from '@browsery/validator';
|
|
2
2
|
import { validator, } from '../../core/index.js';
|
|
3
3
|
/**
|
|
4
|
-
* Validates
|
|
4
|
+
* Validates that a string is a valid EAN (European Article Number).
|
|
5
|
+
* Delegates to `validatorJS.isEAN(input)` (checksum-validated EAN-8/EAN-13
|
|
6
|
+
* style codes).
|
|
5
7
|
* @validator isEAN
|
|
8
|
+
* @param options - Validation options.
|
|
9
|
+
* @returns The input string, unchanged, if valid.
|
|
10
|
+
* @throws if `input` is not a valid EAN: `Value must be a valid EAN (European Article Number)`
|
|
11
|
+
* @example
|
|
12
|
+
* ```ts
|
|
13
|
+
* isEAN('4006381333931'); // => '4006381333931'
|
|
14
|
+
* isEAN('1234567890123'); // throws ValidationError: "Value must be a valid EAN (European Article Number)"
|
|
15
|
+
* ```
|
|
6
16
|
*/
|
|
7
17
|
export function isEAN(options) {
|
|
8
18
|
return validator(isEAN.name, (input, context, _this) => {
|
|
@@ -1,7 +1,19 @@
|
|
|
1
1
|
import { type ValidationOptions } from '../../core/index.js';
|
|
2
2
|
/**
|
|
3
|
-
* Validates
|
|
3
|
+
* Validates that a string is a well-formed email address. Wraps
|
|
4
|
+
* `validatorJS.isEmail`, always passing `allow_display_name: true` as a
|
|
5
|
+
* base, then layers additional checks (display name requirement/
|
|
6
|
+
* prohibition, host black/white list, blacklisted characters) as separate
|
|
7
|
+
* re-validation passes, each producing a specific error message.
|
|
4
8
|
* @validator isEmail
|
|
9
|
+
* @param options - Validation options.
|
|
10
|
+
* @returns The input string, unchanged, if valid.
|
|
11
|
+
* @throws if `input` is not a well-formed email address: `Value must match required e-mail format`
|
|
12
|
+
* @example
|
|
13
|
+
* ```ts
|
|
14
|
+
* isEmail('me@domain.com'); // => 'me@domain.com'
|
|
15
|
+
* isEmail('invalid'); // throws ValidationError: "Value must match required e-mail format"
|
|
16
|
+
* ```
|
|
5
17
|
*/
|
|
6
18
|
export declare function isEmail(options?: isEmail.Options): import("../../core/validator.js").Validator<string, string, import("../../core/types.js").ExecutionOptions>;
|
|
7
19
|
export declare namespace isEmail {
|
|
@@ -9,38 +21,38 @@ export declare namespace isEmail {
|
|
|
9
21
|
/**
|
|
10
22
|
* If set to `true`, the validator will also match `Display Name <email-address>`.
|
|
11
23
|
*
|
|
12
|
-
* @
|
|
24
|
+
* @defaultValue false
|
|
13
25
|
*/
|
|
14
26
|
allowDisplayName?: boolean;
|
|
15
27
|
/**
|
|
16
28
|
* If set to `true`, the validator will reject strings without the format `Display Name <email-address>`.
|
|
17
29
|
*
|
|
18
|
-
* @
|
|
30
|
+
* @defaultValue false
|
|
19
31
|
*/
|
|
20
32
|
requireDisplayName?: boolean;
|
|
21
33
|
/**
|
|
22
34
|
* If set to `false`, the validator will not allow any non-English UTF8 character in email address' local part.
|
|
23
35
|
*
|
|
24
|
-
* @
|
|
36
|
+
* @defaultValue true
|
|
25
37
|
*/
|
|
26
38
|
utf8LocalPart?: boolean;
|
|
27
39
|
/**
|
|
28
40
|
* If set to `true`, the validator will not check for the standard max length of an email.
|
|
29
41
|
*
|
|
30
|
-
* @
|
|
42
|
+
* @defaultValue false
|
|
31
43
|
*/
|
|
32
44
|
ignoreMaxLength?: boolean;
|
|
33
45
|
/**
|
|
34
46
|
* If set to `true`, the validator will allow IP addresses in the host part.
|
|
35
47
|
*
|
|
36
|
-
* @
|
|
48
|
+
* @defaultValue false
|
|
37
49
|
*/
|
|
38
50
|
allowIpDomain?: boolean;
|
|
39
51
|
/**
|
|
40
52
|
* If set to `true`, some additional validation will be enabled,
|
|
41
53
|
* e.g. disallowing certain syntactically valid email addresses that are rejected by GMail.
|
|
42
54
|
*
|
|
43
|
-
* @
|
|
55
|
+
* @defaultValue false
|
|
44
56
|
*/
|
|
45
57
|
domainSpecificValidation?: boolean;
|
|
46
58
|
/**
|
|
@@ -1,8 +1,20 @@
|
|
|
1
1
|
import validatorJS, {} from '@browsery/validator';
|
|
2
2
|
import { validator, } from '../../core/index.js';
|
|
3
3
|
/**
|
|
4
|
-
* Validates
|
|
4
|
+
* Validates that a string is a well-formed email address. Wraps
|
|
5
|
+
* `validatorJS.isEmail`, always passing `allow_display_name: true` as a
|
|
6
|
+
* base, then layers additional checks (display name requirement/
|
|
7
|
+
* prohibition, host black/white list, blacklisted characters) as separate
|
|
8
|
+
* re-validation passes, each producing a specific error message.
|
|
5
9
|
* @validator isEmail
|
|
10
|
+
* @param options - Validation options.
|
|
11
|
+
* @returns The input string, unchanged, if valid.
|
|
12
|
+
* @throws if `input` is not a well-formed email address: `Value must match required e-mail format`
|
|
13
|
+
* @example
|
|
14
|
+
* ```ts
|
|
15
|
+
* isEmail('me@domain.com'); // => 'me@domain.com'
|
|
16
|
+
* isEmail('invalid'); // throws ValidationError: "Value must match required e-mail format"
|
|
17
|
+
* ```
|
|
6
18
|
*/
|
|
7
19
|
export function isEmail(options) {
|
|
8
20
|
const emailOptions = {
|
|
@@ -1,7 +1,16 @@
|
|
|
1
1
|
import { type ValidationOptions } from '../../core/index.js';
|
|
2
2
|
/**
|
|
3
|
-
* Validates
|
|
3
|
+
* Validates that a string is a valid Ethereum (ETH) address. Delegates to
|
|
4
|
+
* `validatorJS.isEthereumAddress`.
|
|
4
5
|
* @validator isETHAddress
|
|
6
|
+
* @param options - Validation options.
|
|
7
|
+
* @returns The input string, unchanged, if valid.
|
|
8
|
+
* @throws if `input` is not a valid ETH address: `Value must be valid ETH (Ethereum) address`
|
|
9
|
+
* @example
|
|
10
|
+
* ```ts
|
|
11
|
+
* isETHAddress('0xb794f5ea0ba39494ce839613fffba74279579268'); // => '0xb794f5ea0ba39494ce839613fffba74279579268'
|
|
12
|
+
* isETHAddress('0xnothex'); // throws ValidationError: "Value must be valid ETH (Ethereum) address"
|
|
13
|
+
* ```
|
|
5
14
|
*/
|
|
6
15
|
export declare function isETHAddress(options?: isETHAddress.Options): import("../../core/validator.js").Validator<string, string, import("../../core/types.js").ExecutionOptions>;
|
|
7
16
|
export declare namespace isETHAddress {
|
|
@@ -1,8 +1,17 @@
|
|
|
1
1
|
import validatorJS from '@browsery/validator';
|
|
2
2
|
import { validator, } from '../../core/index.js';
|
|
3
3
|
/**
|
|
4
|
-
* Validates
|
|
4
|
+
* Validates that a string is a valid Ethereum (ETH) address. Delegates to
|
|
5
|
+
* `validatorJS.isEthereumAddress`.
|
|
5
6
|
* @validator isETHAddress
|
|
7
|
+
* @param options - Validation options.
|
|
8
|
+
* @returns The input string, unchanged, if valid.
|
|
9
|
+
* @throws if `input` is not a valid ETH address: `Value must be valid ETH (Ethereum) address`
|
|
10
|
+
* @example
|
|
11
|
+
* ```ts
|
|
12
|
+
* isETHAddress('0xb794f5ea0ba39494ce839613fffba74279579268'); // => '0xb794f5ea0ba39494ce839613fffba74279579268'
|
|
13
|
+
* isETHAddress('0xnothex'); // throws ValidationError: "Value must be valid ETH (Ethereum) address"
|
|
14
|
+
* ```
|
|
6
15
|
*/
|
|
7
16
|
export function isETHAddress(options) {
|
|
8
17
|
return validator(isETHAddress.name, (input, context, _this) => {
|
|
@@ -1,14 +1,25 @@
|
|
|
1
1
|
import { type ValidationOptions } from '../../core/index.js';
|
|
2
2
|
/**
|
|
3
|
-
* Validates
|
|
3
|
+
* Validates that a string is a fully qualified domain name (e.g.
|
|
4
|
+
* `domain.com`). Delegates to `validatorJS.isFQDN(input, { allow_wildcard })`.
|
|
5
|
+
* Only `allowWildcard` is forwarded; other underlying options
|
|
6
|
+
* (`require_tld`, `allow_underscores`, etc.) are not currently exposed.
|
|
4
7
|
* @validator isFQDN
|
|
8
|
+
* @param options - Validation options.
|
|
9
|
+
* @returns The input string, unchanged, if valid.
|
|
10
|
+
* @throws if `input` is not a valid FQDN: `Value must be valid FQDN`
|
|
11
|
+
* @example
|
|
12
|
+
* ```ts
|
|
13
|
+
* isFQDN('example.com'); // => 'example.com'
|
|
14
|
+
* isFQDN('*.example.com'); // throws ValidationError: "Value must be valid FQDN" (wildcard rejected by default)
|
|
15
|
+
* ```
|
|
5
16
|
*/
|
|
6
17
|
export declare function isFQDN(options?: isFQDN.Options): import("../../core/validator.js").Validator<string, string, import("../../core/types.js").ExecutionOptions>;
|
|
7
18
|
export declare namespace isFQDN {
|
|
8
19
|
interface Options extends ValidationOptions {
|
|
9
20
|
/**
|
|
10
21
|
* If set to true, the validator will allow domain starting with `*.` (e.g. `*.example.com` or `*.shop.example.com`).
|
|
11
|
-
* @
|
|
22
|
+
* @defaultValue false
|
|
12
23
|
*/
|
|
13
24
|
allowWildcard?: boolean;
|
|
14
25
|
}
|
|
@@ -1,8 +1,19 @@
|
|
|
1
1
|
import validatorJS, {} from '@browsery/validator';
|
|
2
2
|
import { validator, } from '../../core/index.js';
|
|
3
3
|
/**
|
|
4
|
-
* Validates
|
|
4
|
+
* Validates that a string is a fully qualified domain name (e.g.
|
|
5
|
+
* `domain.com`). Delegates to `validatorJS.isFQDN(input, { allow_wildcard })`.
|
|
6
|
+
* Only `allowWildcard` is forwarded; other underlying options
|
|
7
|
+
* (`require_tld`, `allow_underscores`, etc.) are not currently exposed.
|
|
5
8
|
* @validator isFQDN
|
|
9
|
+
* @param options - Validation options.
|
|
10
|
+
* @returns The input string, unchanged, if valid.
|
|
11
|
+
* @throws if `input` is not a valid FQDN: `Value must be valid FQDN`
|
|
12
|
+
* @example
|
|
13
|
+
* ```ts
|
|
14
|
+
* isFQDN('example.com'); // => 'example.com'
|
|
15
|
+
* isFQDN('*.example.com'); // throws ValidationError: "Value must be valid FQDN" (wildcard rejected by default)
|
|
16
|
+
* ```
|
|
6
17
|
*/
|
|
7
18
|
export function isFQDN(options) {
|
|
8
19
|
const opts = {
|
|
@@ -1,10 +1,26 @@
|
|
|
1
1
|
import { type HashAlgorithm as _HashAlgorithm } from '@browsery/validator';
|
|
2
2
|
import { type ValidationOptions } from '../../core/index.js';
|
|
3
3
|
/**
|
|
4
|
-
* Validates
|
|
4
|
+
* Validates that a string is a hash digest of the given algorithm. Delegates
|
|
5
|
+
* to `validatorJS.isHash(input, algorithm)`, which checks that the string is
|
|
6
|
+
* a hex string of the length expected for the given algorithm.
|
|
5
7
|
* @validator isHash
|
|
8
|
+
* @param algorithm - The hash algorithm the input is expected to match.
|
|
9
|
+
* @param options - Validation options.
|
|
10
|
+
* @returns The validated hash string, unchanged.
|
|
11
|
+
* @throws `Value must be a valid ${algorithm} hash` when the input is not a
|
|
12
|
+
* string, or is not a hex string of the expected length for `algorithm`.
|
|
13
|
+
* @example
|
|
14
|
+
* ```ts
|
|
15
|
+
* import { vg } from 'valgen';
|
|
16
|
+
*
|
|
17
|
+
* const isMd5 = vg.isHash('md5');
|
|
18
|
+
* isMd5('5d41402abc4b2a76b9719d911017c592'); // => '5d41402abc4b2a76b9719d911017c592'
|
|
19
|
+
* isMd5('too-short'); // throws ValidationError: "Value must be a valid md5 hash"
|
|
20
|
+
* ```
|
|
6
21
|
*/
|
|
7
22
|
export declare function isHash(algorithm: isHash.HashAlgorithm, options?: ValidationOptions): import("../../core/validator.js").Validator<string, string, import("../../core/types.js").ExecutionOptions>;
|
|
8
23
|
export declare namespace isHash {
|
|
24
|
+
/** The hash algorithms accepted by {@link isHash}'s `algorithm` argument. */
|
|
9
25
|
type HashAlgorithm = _HashAlgorithm;
|
|
10
26
|
}
|
|
@@ -1,8 +1,23 @@
|
|
|
1
1
|
import validatorJS, {} from '@browsery/validator';
|
|
2
2
|
import { validator, } from '../../core/index.js';
|
|
3
3
|
/**
|
|
4
|
-
* Validates
|
|
4
|
+
* Validates that a string is a hash digest of the given algorithm. Delegates
|
|
5
|
+
* to `validatorJS.isHash(input, algorithm)`, which checks that the string is
|
|
6
|
+
* a hex string of the length expected for the given algorithm.
|
|
5
7
|
* @validator isHash
|
|
8
|
+
* @param algorithm - The hash algorithm the input is expected to match.
|
|
9
|
+
* @param options - Validation options.
|
|
10
|
+
* @returns The validated hash string, unchanged.
|
|
11
|
+
* @throws `Value must be a valid ${algorithm} hash` when the input is not a
|
|
12
|
+
* string, or is not a hex string of the expected length for `algorithm`.
|
|
13
|
+
* @example
|
|
14
|
+
* ```ts
|
|
15
|
+
* import { vg } from 'valgen';
|
|
16
|
+
*
|
|
17
|
+
* const isMd5 = vg.isHash('md5');
|
|
18
|
+
* isMd5('5d41402abc4b2a76b9719d911017c592'); // => '5d41402abc4b2a76b9719d911017c592'
|
|
19
|
+
* isMd5('too-short'); // throws ValidationError: "Value must be a valid md5 hash"
|
|
20
|
+
* ```
|
|
6
21
|
*/
|
|
7
22
|
export function isHash(algorithm, options) {
|
|
8
23
|
return validator(isHash.name, (input, context, _this) => {
|
|
@@ -1,7 +1,19 @@
|
|
|
1
1
|
import { type ValidationOptions } from '../../core/index.js';
|
|
2
2
|
/**
|
|
3
|
-
* Validates
|
|
3
|
+
* Validates that a string is a valid hexadecimal color (e.g. `#fff`,
|
|
4
|
+
* `#ffffff`). Delegates to `validatorJS.isHexColor(input)`.
|
|
4
5
|
* @validator isHexColor
|
|
6
|
+
* @param options - Validation options.
|
|
7
|
+
* @returns The validated hex color string, unchanged.
|
|
8
|
+
* @throws `Value must be a valid Hex Color` when the input is not a string,
|
|
9
|
+
* or is not a valid hex color.
|
|
10
|
+
* @example
|
|
11
|
+
* ```ts
|
|
12
|
+
* import { isHexColor } from 'valgen';
|
|
13
|
+
*
|
|
14
|
+
* isHexColor('#fff'); // => '#fff'
|
|
15
|
+
* isHexColor('notacolor'); // throws ValidationError: "Value must be a valid Hex Color"
|
|
16
|
+
* ```
|
|
5
17
|
*/
|
|
6
18
|
export declare function isHexColor(options?: isHexColor.Options): import("../../core/validator.js").Validator<string, string, import("../../core/types.js").ExecutionOptions>;
|
|
7
19
|
export declare namespace isHexColor {
|
|
@@ -1,8 +1,20 @@
|
|
|
1
1
|
import validatorJS from '@browsery/validator';
|
|
2
2
|
import { validator, } from '../../core/index.js';
|
|
3
3
|
/**
|
|
4
|
-
* Validates
|
|
4
|
+
* Validates that a string is a valid hexadecimal color (e.g. `#fff`,
|
|
5
|
+
* `#ffffff`). Delegates to `validatorJS.isHexColor(input)`.
|
|
5
6
|
* @validator isHexColor
|
|
7
|
+
* @param options - Validation options.
|
|
8
|
+
* @returns The validated hex color string, unchanged.
|
|
9
|
+
* @throws `Value must be a valid Hex Color` when the input is not a string,
|
|
10
|
+
* or is not a valid hex color.
|
|
11
|
+
* @example
|
|
12
|
+
* ```ts
|
|
13
|
+
* import { isHexColor } from 'valgen';
|
|
14
|
+
*
|
|
15
|
+
* isHexColor('#fff'); // => '#fff'
|
|
16
|
+
* isHexColor('notacolor'); // throws ValidationError: "Value must be a valid Hex Color"
|
|
17
|
+
* ```
|
|
6
18
|
*/
|
|
7
19
|
export function isHexColor(options) {
|
|
8
20
|
return validator(isHexColor.name, (input, context, _this) => {
|
|
@@ -1,7 +1,19 @@
|
|
|
1
1
|
import { type ValidationOptions } from '../../core/index.js';
|
|
2
2
|
/**
|
|
3
|
-
*
|
|
3
|
+
* Validates that a string is a hexadecimal number. Delegates to
|
|
4
|
+
* `validatorJS.isHexadecimal(input)`.
|
|
4
5
|
* @validator isHex
|
|
6
|
+
* @param options - Validation options.
|
|
7
|
+
* @returns The validated hexadecimal string, unchanged.
|
|
8
|
+
* @throws `Value must be an hexadecimal string` when the input is not a
|
|
9
|
+
* string, or is not a valid hexadecimal number.
|
|
10
|
+
* @example
|
|
11
|
+
* ```ts
|
|
12
|
+
* import { isHex } from 'valgen';
|
|
13
|
+
*
|
|
14
|
+
* isHex('1a2B3c'); // => '1a2B3c'
|
|
15
|
+
* isHex('zzz'); // throws ValidationError: "Value must be an hexadecimal string"
|
|
16
|
+
* ```
|
|
5
17
|
*/
|
|
6
18
|
export declare function isHex(options?: isHex.Options): import("../../core/validator.js").Validator<string, string, import("../../core/types.js").ExecutionOptions>;
|
|
7
19
|
export declare namespace isHex {
|
|
@@ -1,8 +1,20 @@
|
|
|
1
1
|
import validatorJS from '@browsery/validator';
|
|
2
2
|
import { validator, } from '../../core/index.js';
|
|
3
3
|
/**
|
|
4
|
-
*
|
|
4
|
+
* Validates that a string is a hexadecimal number. Delegates to
|
|
5
|
+
* `validatorJS.isHexadecimal(input)`.
|
|
5
6
|
* @validator isHex
|
|
7
|
+
* @param options - Validation options.
|
|
8
|
+
* @returns The validated hexadecimal string, unchanged.
|
|
9
|
+
* @throws `Value must be an hexadecimal string` when the input is not a
|
|
10
|
+
* string, or is not a valid hexadecimal number.
|
|
11
|
+
* @example
|
|
12
|
+
* ```ts
|
|
13
|
+
* import { isHex } from 'valgen';
|
|
14
|
+
*
|
|
15
|
+
* isHex('1a2B3c'); // => '1a2B3c'
|
|
16
|
+
* isHex('zzz'); // throws ValidationError: "Value must be an hexadecimal string"
|
|
17
|
+
* ```
|
|
6
18
|
*/
|
|
7
19
|
export function isHex(options) {
|
|
8
20
|
return validator(isHex.name, (input, context, _this) => {
|
|
@@ -1,11 +1,42 @@
|
|
|
1
|
-
import { type IsIBANOptions as _IsIBANOptions } from '@browsery/validator';
|
|
1
|
+
import { type IBANLocale as _IBANLocale, type IsIBANOptions as _IsIBANOptions } from '@browsery/validator';
|
|
2
2
|
import { type ValidationOptions } from '../../core/index.js';
|
|
3
3
|
/**
|
|
4
|
-
* Validates
|
|
4
|
+
* Validates that a string is a valid IBAN (International Bank Account
|
|
5
|
+
* Number). Delegates to `validatorJS.isIBAN(input, options)`, which checks
|
|
6
|
+
* structure and the mod-97 checksum for the country.
|
|
5
7
|
* @validator isIBAN
|
|
8
|
+
* @param options - Validation options, including `whitelist`/`blacklist`
|
|
9
|
+
* country restrictions.
|
|
10
|
+
* @returns The validated IBAN string, unchanged.
|
|
11
|
+
* @throws `Value must be a valid IBAN (International Bank Account Number)`
|
|
12
|
+
* when the input is not a string, fails the checksum, or is excluded by
|
|
13
|
+
* `whitelist`/`blacklist`.
|
|
14
|
+
* @example
|
|
15
|
+
* ```ts
|
|
16
|
+
* import { isIBAN, vg } from 'valgen';
|
|
17
|
+
*
|
|
18
|
+
* isIBAN('DE89370400440532013000'); // => 'DE89370400440532013000'
|
|
19
|
+
* isIBAN('DE89370400440532013001'); // throws ValidationError: "Value must be a valid IBAN (International Bank Account Number)"
|
|
20
|
+
*
|
|
21
|
+
* const deOnly = vg.isIBAN({ whitelist: ['DE'] });
|
|
22
|
+
* deOnly('DE89370400440532013000'); // => 'DE89370400440532013000'
|
|
23
|
+
* ```
|
|
6
24
|
*/
|
|
7
25
|
export declare function isIBAN(options?: isIBAN.Options): import("../../core/validator.js").Validator<string, string, import("../../core/types.js").ExecutionOptions>;
|
|
8
26
|
export declare namespace isIBAN {
|
|
9
27
|
interface Options extends ValidationOptions, _IsIBANOptions {
|
|
28
|
+
/**
|
|
29
|
+
* Only accept IBANs from these country codes.
|
|
30
|
+
*
|
|
31
|
+
* @defaultValue undefined
|
|
32
|
+
*/
|
|
33
|
+
whitelist?: IBANLocale[];
|
|
34
|
+
/**
|
|
35
|
+
* Reject IBANs from these country codes.
|
|
36
|
+
*
|
|
37
|
+
* @defaultValue undefined
|
|
38
|
+
*/
|
|
39
|
+
blacklist?: IBANLocale[];
|
|
10
40
|
}
|
|
41
|
+
type IBANLocale = _IBANLocale;
|
|
11
42
|
}
|
|
@@ -1,8 +1,26 @@
|
|
|
1
1
|
import validatorJS, {} from '@browsery/validator';
|
|
2
2
|
import { validator, } from '../../core/index.js';
|
|
3
3
|
/**
|
|
4
|
-
* Validates
|
|
4
|
+
* Validates that a string is a valid IBAN (International Bank Account
|
|
5
|
+
* Number). Delegates to `validatorJS.isIBAN(input, options)`, which checks
|
|
6
|
+
* structure and the mod-97 checksum for the country.
|
|
5
7
|
* @validator isIBAN
|
|
8
|
+
* @param options - Validation options, including `whitelist`/`blacklist`
|
|
9
|
+
* country restrictions.
|
|
10
|
+
* @returns The validated IBAN string, unchanged.
|
|
11
|
+
* @throws `Value must be a valid IBAN (International Bank Account Number)`
|
|
12
|
+
* when the input is not a string, fails the checksum, or is excluded by
|
|
13
|
+
* `whitelist`/`blacklist`.
|
|
14
|
+
* @example
|
|
15
|
+
* ```ts
|
|
16
|
+
* import { isIBAN, vg } from 'valgen';
|
|
17
|
+
*
|
|
18
|
+
* isIBAN('DE89370400440532013000'); // => 'DE89370400440532013000'
|
|
19
|
+
* isIBAN('DE89370400440532013001'); // throws ValidationError: "Value must be a valid IBAN (International Bank Account Number)"
|
|
20
|
+
*
|
|
21
|
+
* const deOnly = vg.isIBAN({ whitelist: ['DE'] });
|
|
22
|
+
* deOnly('DE89370400440532013000'); // => 'DE89370400440532013000'
|
|
23
|
+
* ```
|
|
6
24
|
*/
|
|
7
25
|
export function isIBAN(options) {
|
|
8
26
|
return validator(isIBAN.name, (input, context, _this) => {
|