valgen 5.9.0 → 5.10.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/CHANGELOG.md +8 -0
- package/README.md +3 -3
- package/cjs/core/utilities.js +4 -4
- package/cjs/tsconfig-build-cjs.tsbuildinfo +1 -0
- package/esm/core/utilities.js +1 -1
- package/esm/rules/format-rules/is-alpha.js +1 -1
- package/esm/rules/format-rules/is-ascii.js +1 -1
- package/esm/rules/format-rules/is-base64.js +1 -1
- package/esm/rules/format-rules/is-btc-address.js +1 -1
- package/esm/rules/format-rules/is-credit-card.js +1 -1
- package/esm/rules/format-rules/is-decimal.js +1 -1
- package/esm/rules/format-rules/is-ean.js +1 -1
- package/esm/rules/format-rules/is-email.js +1 -1
- package/esm/rules/format-rules/is-eth-address.js +1 -1
- package/esm/rules/format-rules/is-fqdn.js +1 -1
- package/esm/rules/format-rules/is-hash.js +1 -1
- package/esm/rules/format-rules/is-hex-color.js +1 -1
- package/esm/rules/format-rules/is-hex.js +1 -1
- package/esm/rules/format-rules/is-iban.js +1 -1
- package/esm/rules/format-rules/is-ip.js +1 -1
- package/esm/rules/format-rules/is-issn.js +1 -1
- package/esm/rules/format-rules/is-jwt.js +1 -1
- package/esm/rules/format-rules/is-lowercase.js +1 -1
- package/esm/rules/format-rules/is-mac-address.js +1 -1
- package/esm/rules/format-rules/is-mobile-phone.js +1 -1
- package/esm/rules/format-rules/is-passport-number.js +1 -1
- package/esm/rules/format-rules/is-port.js +1 -1
- package/esm/rules/format-rules/is-url.js +1 -1
- package/esm/rules/format-rules/is-uuid.js +1 -1
- package/esm/rules/format-rules/is-vat-number.js +1 -1
- package/esm/rules/logical-rules/is-defined.js +1 -1
- package/esm/rules/logical-rules/is-empty.js +1 -1
- package/esm/rules/type-rules/is-bigint.js +1 -1
- package/esm/rules/type-rules/is-date.js +1 -1
- package/esm/rules/type-rules/is-null.js +1 -1
- package/esm/rules/type-rules/is-number.js +1 -1
- package/esm/rules/utility-rules/exists.js +1 -1
- package/esm/rules/utility-rules/union.js +1 -1
- package/esm/tsconfig-build-esm.tsbuildinfo +1 -0
- package/package.json +3 -3
- package/types/core/utilities.d.ts +2 -1
- package/types/core/validation-error.d.ts +1 -1
- package/types/core/validator.d.ts +2 -2
- package/types/rules/format-rules/is-alpha.d.ts +1 -1
- package/types/rules/format-rules/is-ascii.d.ts +1 -1
- package/types/rules/format-rules/is-base64.d.ts +1 -1
- package/types/rules/format-rules/is-btc-address.d.ts +1 -1
- package/types/rules/format-rules/is-credit-card.d.ts +1 -1
- package/types/rules/format-rules/is-decimal.d.ts +1 -1
- package/types/rules/format-rules/is-ean.d.ts +1 -1
- package/types/rules/format-rules/is-email.d.ts +1 -1
- package/types/rules/format-rules/is-eth-address.d.ts +1 -1
- package/types/rules/format-rules/is-fqdn.d.ts +1 -1
- package/types/rules/format-rules/is-hash.d.ts +1 -1
- package/types/rules/format-rules/is-hex-color.d.ts +1 -1
- package/types/rules/format-rules/is-hex.d.ts +1 -1
- package/types/rules/format-rules/is-iban.d.ts +1 -1
- package/types/rules/format-rules/is-ip.d.ts +1 -1
- package/types/rules/format-rules/is-issn.d.ts +1 -1
- package/types/rules/format-rules/is-jwt.d.ts +1 -1
- package/types/rules/format-rules/is-lowercase.d.ts +1 -1
- package/types/rules/format-rules/is-mac-address.d.ts +1 -1
- package/types/rules/format-rules/is-mobile-phone.d.ts +1 -1
- package/types/rules/format-rules/is-object-id.d.ts +1 -1
- package/types/rules/format-rules/is-passport-number.d.ts +1 -1
- package/types/rules/format-rules/is-port.d.ts +1 -1
- package/types/rules/format-rules/is-url.d.ts +1 -1
- package/types/rules/format-rules/is-uuid.d.ts +1 -1
- package/types/rules/format-rules/is-vat-number.d.ts +1 -1
- package/types/rules/format-rules/matches.d.ts +1 -1
- package/types/rules/logical-rules/is-defined.d.ts +1 -1
- package/types/rules/logical-rules/is-empty.d.ts +1 -1
- package/types/rules/logical-rules/range.d.ts +1 -1
- package/types/rules/type-rules/is-array.d.ts +1 -1
- package/types/rules/type-rules/is-bigint.d.ts +1 -1
- package/types/rules/type-rules/is-boolean.d.ts +1 -1
- package/types/rules/type-rules/is-date.d.ts +1 -1
- package/types/rules/type-rules/is-enum.d.ts +1 -1
- package/types/rules/type-rules/is-integer.d.ts +1 -1
- package/types/rules/type-rules/is-null.d.ts +1 -1
- package/types/rules/type-rules/is-number.d.ts +1 -1
- package/types/rules/type-rules/is-object.d.ts +1 -1
- package/types/rules/type-rules/is-record.d.ts +1 -1
- package/types/rules/type-rules/is-string.d.ts +1 -1
- package/types/rules/type-rules/is-tuple.d.ts +1 -1
- package/types/rules/type-rules/is-undefined.d.ts +1 -1
- package/types/rules/utility-rules/exists.d.ts +1 -1
- package/types/rules/utility-rules/optional.d.ts +2 -2
- package/types/rules/utility-rules/pipe.d.ts +1 -1
- package/types/rules/utility-rules/required.d.ts +2 -2
- package/types/rules/utility-rules/union.d.ts +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,11 @@
|
|
|
1
|
+
# v5.10.0
|
|
2
|
+
[2024-09-14]
|
|
3
|
+
|
|
4
|
+
### Changes
|
|
5
|
+
|
|
6
|
+
* chore: Moved from circleci to github actions ([`179e630`](https://github.com/panates/valgen/commit/179e630a1b1327acf995decb88ed86b015a48c6a))
|
|
7
|
+
* fixed: Circular imports ([`f2a83b9`](https://github.com/panates/valgen/commit/f2a83b9f466f1bc5acaabef3ac78f6c567ed7b54))
|
|
8
|
+
|
|
1
9
|
# v5.9.0
|
|
2
10
|
[2024-08-20]
|
|
3
11
|
|
package/README.md
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
[![NPM Version][npm-image]][npm-url]
|
|
4
4
|
[![NPM Downloads][downloads-image]][downloads-url]
|
|
5
|
-
[![
|
|
5
|
+
[![CI Tests][ci-test-image]][ci-test-url]
|
|
6
6
|
[![Test Coverage][coveralls-image]][coveralls-url]
|
|
7
7
|
|
|
8
8
|
Fast runtime type validator, converter and io (encoding/decoding) library.
|
|
@@ -20,8 +20,8 @@ Fast runtime type validator, converter and io (encoding/decoding) library.
|
|
|
20
20
|
|
|
21
21
|
[npm-image]: https://img.shields.io/npm/v/valgen.svg
|
|
22
22
|
[npm-url]: https://npmjs.org/package/valgen
|
|
23
|
-
[
|
|
24
|
-
[
|
|
23
|
+
[ci-test-image]: https://github.com/panates/valgen/actions/workflows/test.yml/badge.svg
|
|
24
|
+
[ci-test-url]: https://github.com/panates/valgen/actions/workflows/test.yml
|
|
25
25
|
[coveralls-image]: https://img.shields.io/coveralls/panates/valgen/master.svg
|
|
26
26
|
[coveralls-url]: https://coveralls.io/r/panates/valgen
|
|
27
27
|
[downloads-image]: https://img.shields.io/npm/dm/valgen.svg
|
package/cjs/core/utilities.js
CHANGED
|
@@ -2,19 +2,19 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.forwardRef = forwardRef;
|
|
4
4
|
exports.iif = iif;
|
|
5
|
-
const
|
|
5
|
+
const validator_js_1 = require("./validator.js");
|
|
6
6
|
/**
|
|
7
7
|
* Forwards codec process to a sub codec. Useful for circular checks
|
|
8
8
|
* @validator forwardRef
|
|
9
9
|
*/
|
|
10
10
|
function forwardRef(fn) {
|
|
11
|
-
return (0,
|
|
11
|
+
return (0, validator_js_1.validator)('forwardRef', (input, context) => {
|
|
12
12
|
const nested = fn(context);
|
|
13
13
|
return nested(input, context);
|
|
14
14
|
});
|
|
15
15
|
}
|
|
16
16
|
function iif(check, _then, _else) {
|
|
17
|
-
return (0,
|
|
17
|
+
return (0, validator_js_1.validator)('iif', (input, context) => {
|
|
18
18
|
let c = _else;
|
|
19
19
|
try {
|
|
20
20
|
if (check(input) !== undefined)
|
|
@@ -23,7 +23,7 @@ function iif(check, _then, _else) {
|
|
|
23
23
|
catch {
|
|
24
24
|
// ignored
|
|
25
25
|
}
|
|
26
|
-
if ((0,
|
|
26
|
+
if ((0, validator_js_1.isValidator)(c))
|
|
27
27
|
return c(input, context);
|
|
28
28
|
return c;
|
|
29
29
|
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"root":["../../src/constants.ts","../../src/factories.ts","../../src/index.ts","../../src/core/constants.ts","../../src/core/context.ts","../../src/core/index.ts","../../src/core/types.ts","../../src/core/utilities.ts","../../src/core/validation-error.ts","../../src/core/validator.ts","../../src/helpers/object.utils.ts","../../src/helpers/omit-undefined.ts","../../src/helpers/string.utils.ts","../../src/rules/index.ts","../../src/rules/format-rules/is-alpha.ts","../../src/rules/format-rules/is-ascii.ts","../../src/rules/format-rules/is-base64.ts","../../src/rules/format-rules/is-btc-address.ts","../../src/rules/format-rules/is-credit-card.ts","../../src/rules/format-rules/is-decimal.ts","../../src/rules/format-rules/is-ean.ts","../../src/rules/format-rules/is-email.ts","../../src/rules/format-rules/is-eth-address.ts","../../src/rules/format-rules/is-fqdn.ts","../../src/rules/format-rules/is-hash.ts","../../src/rules/format-rules/is-hex-color.ts","../../src/rules/format-rules/is-hex.ts","../../src/rules/format-rules/is-iban.ts","../../src/rules/format-rules/is-ip.ts","../../src/rules/format-rules/is-issn.ts","../../src/rules/format-rules/is-jwt.ts","../../src/rules/format-rules/is-lowercase.ts","../../src/rules/format-rules/is-mac-address.ts","../../src/rules/format-rules/is-mobile-phone.ts","../../src/rules/format-rules/is-object-id.ts","../../src/rules/format-rules/is-passport-number.ts","../../src/rules/format-rules/is-port.ts","../../src/rules/format-rules/is-url.ts","../../src/rules/format-rules/is-uuid.ts","../../src/rules/format-rules/is-vat-number.ts","../../src/rules/format-rules/matches.ts","../../src/rules/logical-rules/is-defined.ts","../../src/rules/logical-rules/is-empty.ts","../../src/rules/logical-rules/range.ts","../../src/rules/type-rules/is-any.ts","../../src/rules/type-rules/is-array.ts","../../src/rules/type-rules/is-bigint.ts","../../src/rules/type-rules/is-boolean.ts","../../src/rules/type-rules/is-date.ts","../../src/rules/type-rules/is-enum.ts","../../src/rules/type-rules/is-integer.ts","../../src/rules/type-rules/is-null.ts","../../src/rules/type-rules/is-number.ts","../../src/rules/type-rules/is-object.ts","../../src/rules/type-rules/is-record.ts","../../src/rules/type-rules/is-string.ts","../../src/rules/type-rules/is-tuple.ts","../../src/rules/type-rules/is-undefined.ts","../../src/rules/utility-rules/exists.ts","../../src/rules/utility-rules/get-length.ts","../../src/rules/utility-rules/optional.ts","../../src/rules/utility-rules/pipe.ts","../../src/rules/utility-rules/required.ts","../../src/rules/utility-rules/union.ts"],"version":"5.6.2"}
|
package/esm/core/utilities.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { formatISO, parseISO } from 'date-fns';
|
|
2
|
-
import { validator } from '../../core/index.js';
|
|
2
|
+
import { validator, } from '../../core/index.js';
|
|
3
3
|
/* eslint-disable-next-line max-len */ // noinspection RegExpUnnecessaryNonCapturingGroup
|
|
4
4
|
const DATE_PATTERN =
|
|
5
5
|
// eslint-disable-next-line max-len
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"root":["../../src/constants.ts","../../src/factories.ts","../../src/index.ts","../../src/core/constants.ts","../../src/core/context.ts","../../src/core/index.ts","../../src/core/types.ts","../../src/core/utilities.ts","../../src/core/validation-error.ts","../../src/core/validator.ts","../../src/helpers/object.utils.ts","../../src/helpers/omit-undefined.ts","../../src/helpers/string.utils.ts","../../src/rules/index.ts","../../src/rules/format-rules/is-alpha.ts","../../src/rules/format-rules/is-ascii.ts","../../src/rules/format-rules/is-base64.ts","../../src/rules/format-rules/is-btc-address.ts","../../src/rules/format-rules/is-credit-card.ts","../../src/rules/format-rules/is-decimal.ts","../../src/rules/format-rules/is-ean.ts","../../src/rules/format-rules/is-email.ts","../../src/rules/format-rules/is-eth-address.ts","../../src/rules/format-rules/is-fqdn.ts","../../src/rules/format-rules/is-hash.ts","../../src/rules/format-rules/is-hex-color.ts","../../src/rules/format-rules/is-hex.ts","../../src/rules/format-rules/is-iban.ts","../../src/rules/format-rules/is-ip.ts","../../src/rules/format-rules/is-issn.ts","../../src/rules/format-rules/is-jwt.ts","../../src/rules/format-rules/is-lowercase.ts","../../src/rules/format-rules/is-mac-address.ts","../../src/rules/format-rules/is-mobile-phone.ts","../../src/rules/format-rules/is-object-id.ts","../../src/rules/format-rules/is-passport-number.ts","../../src/rules/format-rules/is-port.ts","../../src/rules/format-rules/is-url.ts","../../src/rules/format-rules/is-uuid.ts","../../src/rules/format-rules/is-vat-number.ts","../../src/rules/format-rules/matches.ts","../../src/rules/logical-rules/is-defined.ts","../../src/rules/logical-rules/is-empty.ts","../../src/rules/logical-rules/range.ts","../../src/rules/type-rules/is-any.ts","../../src/rules/type-rules/is-array.ts","../../src/rules/type-rules/is-bigint.ts","../../src/rules/type-rules/is-boolean.ts","../../src/rules/type-rules/is-date.ts","../../src/rules/type-rules/is-enum.ts","../../src/rules/type-rules/is-integer.ts","../../src/rules/type-rules/is-null.ts","../../src/rules/type-rules/is-number.ts","../../src/rules/type-rules/is-object.ts","../../src/rules/type-rules/is-record.ts","../../src/rules/type-rules/is-string.ts","../../src/rules/type-rules/is-tuple.ts","../../src/rules/type-rules/is-undefined.ts","../../src/rules/utility-rules/exists.ts","../../src/rules/utility-rules/get-length.ts","../../src/rules/utility-rules/optional.ts","../../src/rules/utility-rules/pipe.ts","../../src/rules/utility-rules/required.ts","../../src/rules/utility-rules/union.ts"],"version":"5.6.2"}
|
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": "5.
|
|
4
|
+
"version": "5.10.0",
|
|
5
5
|
"author": "Panates",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"dependencies": {
|
|
8
8
|
"date-fns": "^3.6.0",
|
|
9
9
|
"ts-gems": "^3.5.0",
|
|
10
|
-
"
|
|
11
|
-
"
|
|
10
|
+
"tslib": "^2.7.0",
|
|
11
|
+
"validator": "^13.12.0"
|
|
12
12
|
},
|
|
13
13
|
"type": "module",
|
|
14
14
|
"exports": {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { Nullish } from 'ts-gems';
|
|
1
|
+
import type { Nullish } from 'ts-gems';
|
|
2
2
|
import { kValidatorFn } from './constants.js';
|
|
3
3
|
import { Context } from './context.js';
|
|
4
|
-
import { ErrorIssue, ExecutionOptions, ValidationOptions } from './types.js';
|
|
4
|
+
import type { ErrorIssue, ExecutionOptions, ValidationOptions } from './types.js';
|
|
5
5
|
export type ValidateFunction<T, I = T, R extends Validator<T, I> = Validator<T, I>> = (input: I, context: Context, _this: R) => Nullish<T>;
|
|
6
6
|
export interface Validator<T = any, I = any, O extends ExecutionOptions = ExecutionOptions> {
|
|
7
7
|
(input: I, options?: O, context?: Context): T;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as validatorJS from 'validator';
|
|
2
|
-
import { ValidationOptions } from '../../core/index.js';
|
|
2
|
+
import { type ValidationOptions } from '../../core/index.js';
|
|
3
3
|
export interface Base64ValidatorOptions extends ValidationOptions, validatorJS.IsBase64Options {
|
|
4
4
|
}
|
|
5
5
|
/**
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as validatorJS from 'validator';
|
|
2
|
-
import { ValidationOptions } from '../../core/index.js';
|
|
2
|
+
import { type ValidationOptions } from '../../core/index.js';
|
|
3
3
|
export interface CreditCardValidatorOptions extends ValidationOptions, validatorJS.IsCreditCardOptions {
|
|
4
4
|
}
|
|
5
5
|
/**
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ValidationOptions } from '../../core/index.js';
|
|
1
|
+
import { type ValidationOptions } from '../../core/index.js';
|
|
2
2
|
export interface IsEmailOptions extends ValidationOptions {
|
|
3
3
|
/**
|
|
4
4
|
* If set to `true`, the validator will also match `Display Name <email-address>`.
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ValidationOptions } from '../../core/index.js';
|
|
1
|
+
import { type ValidationOptions } from '../../core/index.js';
|
|
2
2
|
export interface IsFQDNOptions extends ValidationOptions {
|
|
3
3
|
/**
|
|
4
4
|
* If set to true, the validator will allow domain starting with `*.` (e.g. `*.example.com` or `*.shop.example.com`).
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as validatorJS from 'validator';
|
|
2
|
-
import { ValidationOptions } from '../../core/index.js';
|
|
2
|
+
import { type ValidationOptions } from '../../core/index.js';
|
|
3
3
|
export type HashAlgorithm = validatorJS.HashAlgorithm;
|
|
4
4
|
/**
|
|
5
5
|
* Validates if value a hash of type algorithm
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ValidationOptions } from '../../core/index.js';
|
|
1
|
+
import { type ValidationOptions } from '../../core/index.js';
|
|
2
2
|
export interface IsMACAddressOptions extends ValidationOptions {
|
|
3
3
|
/**
|
|
4
4
|
* If set to `true`, the validator will allow MAC addresses without the colons.
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as validatorJS from 'validator';
|
|
2
|
-
import { ValidationOptions } from '../../core/index.js';
|
|
2
|
+
import { type ValidationOptions } from '../../core/index.js';
|
|
3
3
|
export interface IsMobilePhoneOptions extends ValidationOptions {
|
|
4
4
|
/**
|
|
5
5
|
* If this is set to `true`, the mobile phone number must be supplied with the country code and therefore must start with `+`.
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ValidationOptions } from '../../core/index.js';
|
|
1
|
+
import { type ValidationOptions } from '../../core/index.js';
|
|
2
2
|
type IsEmptyInput = string | any[] | object | Set<any> | Map<any, any>;
|
|
3
3
|
/**
|
|
4
4
|
* Checks if value is an empty. Value should be string, array, set, map or object
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ValidationOptions, Validator } from '../../core/index.js';
|
|
1
|
+
import { type ValidationOptions, type Validator } from '../../core/index.js';
|
|
2
2
|
/**
|
|
3
3
|
* Validates if value is "array" and applies validation for each item.
|
|
4
4
|
* Converts input value to array if coerce option is set to 'true'.
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Type, ValidationOptions, Validator as Validator_ } from '../../core/index.js';
|
|
1
|
+
import { type Type, type ValidationOptions, type Validator as Validator_ } from '../../core/index.js';
|
|
2
2
|
export declare namespace IsObject {
|
|
3
3
|
interface Validator<T extends object = object, I = object> extends Validator_<T, I> {
|
|
4
4
|
schema: Schema;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ValidationOptions, Validator } from '../../core/index.js';
|
|
1
|
+
import { type ValidationOptions, type Validator } from '../../core/index.js';
|
|
2
2
|
/**
|
|
3
3
|
* Validates record object according to given "key" and "value" rules
|
|
4
4
|
* Converts properties according to rules if coerce option is set to 'true'.
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ValidationOptions, Validator } from '../../core/index.js';
|
|
1
|
+
import { type ValidationOptions, type Validator } from '../../core/index.js';
|
|
2
2
|
/**
|
|
3
3
|
* Validates if value is "tuple" and applies validation for each item.
|
|
4
4
|
* Converts input value to tuple if coerce option is set to 'true'.
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { Nullish } from 'ts-gems';
|
|
2
|
-
import { ValidationOptions, Validator } from '../../core/index.js';
|
|
1
|
+
import type { Nullish } from 'ts-gems';
|
|
2
|
+
import { type ValidationOptions, type Validator } from '../../core/index.js';
|
|
3
3
|
/**
|
|
4
4
|
* Makes sub-rule optional
|
|
5
5
|
* @validator optional
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { Nullish } from 'ts-gems';
|
|
2
|
-
import { ValidationOptions, Validator } from '../../core/index.js';
|
|
1
|
+
import type { Nullish } from 'ts-gems';
|
|
2
|
+
import { type ValidationOptions, type Validator } from '../../core/index.js';
|
|
3
3
|
/**
|
|
4
4
|
* Makes sub-rule required
|
|
5
5
|
* @validator required
|