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.
Files changed (91) hide show
  1. package/CHANGELOG.md +8 -0
  2. package/README.md +3 -3
  3. package/cjs/core/utilities.js +4 -4
  4. package/cjs/tsconfig-build-cjs.tsbuildinfo +1 -0
  5. package/esm/core/utilities.js +1 -1
  6. package/esm/rules/format-rules/is-alpha.js +1 -1
  7. package/esm/rules/format-rules/is-ascii.js +1 -1
  8. package/esm/rules/format-rules/is-base64.js +1 -1
  9. package/esm/rules/format-rules/is-btc-address.js +1 -1
  10. package/esm/rules/format-rules/is-credit-card.js +1 -1
  11. package/esm/rules/format-rules/is-decimal.js +1 -1
  12. package/esm/rules/format-rules/is-ean.js +1 -1
  13. package/esm/rules/format-rules/is-email.js +1 -1
  14. package/esm/rules/format-rules/is-eth-address.js +1 -1
  15. package/esm/rules/format-rules/is-fqdn.js +1 -1
  16. package/esm/rules/format-rules/is-hash.js +1 -1
  17. package/esm/rules/format-rules/is-hex-color.js +1 -1
  18. package/esm/rules/format-rules/is-hex.js +1 -1
  19. package/esm/rules/format-rules/is-iban.js +1 -1
  20. package/esm/rules/format-rules/is-ip.js +1 -1
  21. package/esm/rules/format-rules/is-issn.js +1 -1
  22. package/esm/rules/format-rules/is-jwt.js +1 -1
  23. package/esm/rules/format-rules/is-lowercase.js +1 -1
  24. package/esm/rules/format-rules/is-mac-address.js +1 -1
  25. package/esm/rules/format-rules/is-mobile-phone.js +1 -1
  26. package/esm/rules/format-rules/is-passport-number.js +1 -1
  27. package/esm/rules/format-rules/is-port.js +1 -1
  28. package/esm/rules/format-rules/is-url.js +1 -1
  29. package/esm/rules/format-rules/is-uuid.js +1 -1
  30. package/esm/rules/format-rules/is-vat-number.js +1 -1
  31. package/esm/rules/logical-rules/is-defined.js +1 -1
  32. package/esm/rules/logical-rules/is-empty.js +1 -1
  33. package/esm/rules/type-rules/is-bigint.js +1 -1
  34. package/esm/rules/type-rules/is-date.js +1 -1
  35. package/esm/rules/type-rules/is-null.js +1 -1
  36. package/esm/rules/type-rules/is-number.js +1 -1
  37. package/esm/rules/utility-rules/exists.js +1 -1
  38. package/esm/rules/utility-rules/union.js +1 -1
  39. package/esm/tsconfig-build-esm.tsbuildinfo +1 -0
  40. package/package.json +3 -3
  41. package/types/core/utilities.d.ts +2 -1
  42. package/types/core/validation-error.d.ts +1 -1
  43. package/types/core/validator.d.ts +2 -2
  44. package/types/rules/format-rules/is-alpha.d.ts +1 -1
  45. package/types/rules/format-rules/is-ascii.d.ts +1 -1
  46. package/types/rules/format-rules/is-base64.d.ts +1 -1
  47. package/types/rules/format-rules/is-btc-address.d.ts +1 -1
  48. package/types/rules/format-rules/is-credit-card.d.ts +1 -1
  49. package/types/rules/format-rules/is-decimal.d.ts +1 -1
  50. package/types/rules/format-rules/is-ean.d.ts +1 -1
  51. package/types/rules/format-rules/is-email.d.ts +1 -1
  52. package/types/rules/format-rules/is-eth-address.d.ts +1 -1
  53. package/types/rules/format-rules/is-fqdn.d.ts +1 -1
  54. package/types/rules/format-rules/is-hash.d.ts +1 -1
  55. package/types/rules/format-rules/is-hex-color.d.ts +1 -1
  56. package/types/rules/format-rules/is-hex.d.ts +1 -1
  57. package/types/rules/format-rules/is-iban.d.ts +1 -1
  58. package/types/rules/format-rules/is-ip.d.ts +1 -1
  59. package/types/rules/format-rules/is-issn.d.ts +1 -1
  60. package/types/rules/format-rules/is-jwt.d.ts +1 -1
  61. package/types/rules/format-rules/is-lowercase.d.ts +1 -1
  62. package/types/rules/format-rules/is-mac-address.d.ts +1 -1
  63. package/types/rules/format-rules/is-mobile-phone.d.ts +1 -1
  64. package/types/rules/format-rules/is-object-id.d.ts +1 -1
  65. package/types/rules/format-rules/is-passport-number.d.ts +1 -1
  66. package/types/rules/format-rules/is-port.d.ts +1 -1
  67. package/types/rules/format-rules/is-url.d.ts +1 -1
  68. package/types/rules/format-rules/is-uuid.d.ts +1 -1
  69. package/types/rules/format-rules/is-vat-number.d.ts +1 -1
  70. package/types/rules/format-rules/matches.d.ts +1 -1
  71. package/types/rules/logical-rules/is-defined.d.ts +1 -1
  72. package/types/rules/logical-rules/is-empty.d.ts +1 -1
  73. package/types/rules/logical-rules/range.d.ts +1 -1
  74. package/types/rules/type-rules/is-array.d.ts +1 -1
  75. package/types/rules/type-rules/is-bigint.d.ts +1 -1
  76. package/types/rules/type-rules/is-boolean.d.ts +1 -1
  77. package/types/rules/type-rules/is-date.d.ts +1 -1
  78. package/types/rules/type-rules/is-enum.d.ts +1 -1
  79. package/types/rules/type-rules/is-integer.d.ts +1 -1
  80. package/types/rules/type-rules/is-null.d.ts +1 -1
  81. package/types/rules/type-rules/is-number.d.ts +1 -1
  82. package/types/rules/type-rules/is-object.d.ts +1 -1
  83. package/types/rules/type-rules/is-record.d.ts +1 -1
  84. package/types/rules/type-rules/is-string.d.ts +1 -1
  85. package/types/rules/type-rules/is-tuple.d.ts +1 -1
  86. package/types/rules/type-rules/is-undefined.d.ts +1 -1
  87. package/types/rules/utility-rules/exists.d.ts +1 -1
  88. package/types/rules/utility-rules/optional.d.ts +2 -2
  89. package/types/rules/utility-rules/pipe.d.ts +1 -1
  90. package/types/rules/utility-rules/required.d.ts +2 -2
  91. 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
- [![CircleCI][circleci-image]][circleci-url]
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
- [circleci-image]: https://circleci.com/gh/panates/valgen/tree/master.svg?style=shield
24
- [circleci-url]: https://circleci.com/gh/panates/valgen/tree/master
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
@@ -2,19 +2,19 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.forwardRef = forwardRef;
4
4
  exports.iif = iif;
5
- const index_js_1 = require("./index.js");
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, index_js_1.validator)('forwardRef', (input, context) => {
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, index_js_1.validator)('iif', (input, context) => {
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, index_js_1.isValidator)(c))
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"}
@@ -1,4 +1,4 @@
1
- import { isValidator, validator, } from './index.js';
1
+ import { isValidator, validator } from './validator.js';
2
2
  /**
3
3
  * Forwards codec process to a sub codec. Useful for circular checks
4
4
  * @validator forwardRef
@@ -1,5 +1,5 @@
1
1
  import * as validatorJS from 'validator';
2
- import { validator } from '../../core/index.js';
2
+ import { validator, } from '../../core/index.js';
3
3
  /**
4
4
  * Check if the string contains only letters (a-zA-Z).
5
5
  * @validator isAlpha
@@ -1,5 +1,5 @@
1
1
  import * as validatorJS from 'validator';
2
- import { validator } from '../../core/index.js';
2
+ import { validator, } from '../../core/index.js';
3
3
  /**
4
4
  * Check if the string contains ASCII chars only.
5
5
  * @validator isAscii
@@ -1,5 +1,5 @@
1
1
  import * as validatorJS from 'validator';
2
- import { validator } from '../../core/index.js';
2
+ import { validator, } from '../../core/index.js';
3
3
  /**
4
4
  * Validates if value is a "Base64" string.
5
5
  * @validator isBase64
@@ -1,5 +1,5 @@
1
1
  import * as validatorJS from 'validator';
2
- import { validator } from '../../core/index.js';
2
+ import { validator, } from '../../core/index.js';
3
3
  /**
4
4
  * Validates if value is a BTC address.
5
5
  * @validator isBtcAddress
@@ -1,5 +1,5 @@
1
1
  import * as validatorJS from 'validator';
2
- import { validator } from '../../core/index.js';
2
+ import { validator, } from '../../core/index.js';
3
3
  /**
4
4
  * Validates if value is a credit card number
5
5
  * @validator isCreditCard
@@ -1,5 +1,5 @@
1
1
  import * as validatorJS from 'validator';
2
- import { validator } from '../../core/index.js';
2
+ import { validator, } from '../../core/index.js';
3
3
  /**
4
4
  * Check if the string represents a decimal number,
5
5
  * such as `0.1`, `.3`, `1.1`, `1.00003`, `4.0` etc.
@@ -1,5 +1,5 @@
1
1
  import * as validatorJS from 'validator';
2
- import { validator } from '../../core/index.js';
2
+ import { validator, } from '../../core/index.js';
3
3
  /**
4
4
  * Validates if value is an EAN (European Article Number)
5
5
  * @validator isEAN
@@ -1,5 +1,5 @@
1
1
  import * as validatorJS from 'validator';
2
- import { validator } from '../../core/index.js';
2
+ import { validator, } from '../../core/index.js';
3
3
  /**
4
4
  * Validates if value is a valid Email
5
5
  * @validator isEmail
@@ -1,5 +1,5 @@
1
1
  import * as validatorJS from 'validator';
2
- import { validator } from '../../core/index.js';
2
+ import { validator, } from '../../core/index.js';
3
3
  /**
4
4
  * Validates if value is a ETH (Ethereum) address.
5
5
  * @validator isETHAddress
@@ -1,5 +1,5 @@
1
1
  import * as validatorJS from 'validator';
2
- import { validator } from '../../core/index.js';
2
+ import { validator, } from '../../core/index.js';
3
3
  /**
4
4
  * Validates if value is an FQDN
5
5
  * @validator isFQDN
@@ -1,5 +1,5 @@
1
1
  import * as validatorJS from 'validator';
2
- import { validator } from '../../core/index.js';
2
+ import { validator, } from '../../core/index.js';
3
3
  /**
4
4
  * Validates if value a hash of type algorithm
5
5
  * @validator isHash
@@ -1,5 +1,5 @@
1
1
  import * as validatorJS from 'validator';
2
- import { validator } from '../../core/index.js';
2
+ import { validator, } from '../../core/index.js';
3
3
  /**
4
4
  * Validates if value is a Hex Color
5
5
  * @validator isHexColor
@@ -1,5 +1,5 @@
1
1
  import * as validatorJS from 'validator';
2
- import { validator } from '../../core/index.js';
2
+ import { validator, } from '../../core/index.js';
3
3
  /**
4
4
  * Check if the string is a hexadecimal number.
5
5
  * @validator isHex
@@ -1,5 +1,5 @@
1
1
  import * as validatorJS from 'validator';
2
- import { validator } from '../../core/index.js';
2
+ import { validator, } from '../../core/index.js';
3
3
  /**
4
4
  * Validates if value is an IBAN (International Bank Account Number)
5
5
  * @validator isIBAN
@@ -1,5 +1,5 @@
1
1
  import * as validatorJS from 'validator';
2
- import { validator } from '../../core/index.js';
2
+ import { validator, } from '../../core/index.js';
3
3
  /**
4
4
  * Validates if value is an IP
5
5
  * @validator isIP
@@ -1,5 +1,5 @@
1
1
  import * as validatorJS from 'validator';
2
- import { validator } from '../../core/index.js';
2
+ import { validator, } from '../../core/index.js';
3
3
  /**
4
4
  * Validates if value is an ISSN
5
5
  * @validator isISSN
@@ -1,5 +1,5 @@
1
1
  import * as validatorJS from 'validator';
2
- import { validator } from '../../core/index.js';
2
+ import { validator, } from '../../core/index.js';
3
3
  /**
4
4
  * Validates if value a valid JWT token
5
5
  * @validator isJWT
@@ -1,5 +1,5 @@
1
1
  import * as validatorJS from 'validator';
2
- import { validator } from '../../core/index.js';
2
+ import { validator, } from '../../core/index.js';
3
3
  /**
4
4
  * Validates if value a Lowercase string
5
5
  * @validator isLowercase
@@ -1,5 +1,5 @@
1
1
  import * as validatorJS from 'validator';
2
- import { validator } from '../../core/index.js';
2
+ import { validator, } from '../../core/index.js';
3
3
  /**
4
4
  * Validates if value is an MACAddress
5
5
  * @validator isMACAddress
@@ -1,5 +1,5 @@
1
1
  import * as validatorJS from 'validator';
2
- import { validator } from '../../core/index.js';
2
+ import { validator, } from '../../core/index.js';
3
3
  /**
4
4
  * Validates if value is a valid Email
5
5
  * @validator isMobilePhone
@@ -1,5 +1,5 @@
1
1
  import * as validatorJS from 'validator';
2
- import { validator } from '../../core/index.js';
2
+ import { validator, } from '../../core/index.js';
3
3
  /**
4
4
  * Validates if value is a passport number
5
5
  * @validator isPassportNumber
@@ -1,5 +1,5 @@
1
1
  import * as validatorJS from 'validator';
2
- import { validator } from '../../core/index.js';
2
+ import { validator, } from '../../core/index.js';
3
3
  /**
4
4
  * Validates if value is a port number
5
5
  * @validator isPort
@@ -1,5 +1,5 @@
1
1
  import * as validatorJS from 'validator';
2
- import { validator } from '../../core/index.js';
2
+ import { validator, } from '../../core/index.js';
3
3
  /**
4
4
  * Validates if value is an URL
5
5
  * @validator isURL
@@ -1,5 +1,5 @@
1
1
  import * as validatorJS from 'validator';
2
- import { validator } from '../../core/index.js';
2
+ import { validator, } from '../../core/index.js';
3
3
  /**
4
4
  * Validates if value is an "UUID".
5
5
  * @validator isUUID
@@ -1,5 +1,5 @@
1
1
  import * as validatorJS from 'validator';
2
- import { validator } from '../../core/index.js';
2
+ import { validator, } from '../../core/index.js';
3
3
  /**
4
4
  * Validates if value is an VAT number
5
5
  * @validator isVAT
@@ -1,4 +1,4 @@
1
- import { validator } from '../../core/index.js';
1
+ import { validator, } from '../../core/index.js';
2
2
  /**
3
3
  * Validates if value is not "undefined" nor "null"
4
4
  * @validator isDefined
@@ -1,4 +1,4 @@
1
- import { validator } from '../../core/index.js';
1
+ import { validator, } from '../../core/index.js';
2
2
  /**
3
3
  * Checks if value is an empty. Value should be string, array, set, map or object
4
4
  * @validator isEmpty
@@ -1,4 +1,4 @@
1
- import { validator } from '../../core/index.js';
1
+ import { validator, } from '../../core/index.js';
2
2
  /**
3
3
  * Validates if value is "BigInt".
4
4
  * Converts input value to number if coerce option is set to 'true'.
@@ -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
@@ -1,4 +1,4 @@
1
- import { validator } from '../../core/index.js';
1
+ import { validator, } from '../../core/index.js';
2
2
  /**
3
3
  * Validates if value is "null".
4
4
  * @validator isNull
@@ -1,4 +1,4 @@
1
- import { validator } from '../../core/index.js';
1
+ import { validator, } from '../../core/index.js';
2
2
  /**
3
3
  * Validates if value is "number".
4
4
  * Converts input value to number if coerce option is set to 'true'.
@@ -1,4 +1,4 @@
1
- import { validator } from '../../core/index.js';
1
+ import { validator, } from '../../core/index.js';
2
2
  /**
3
3
  * Validates if property exists
4
4
  * @validator exists
@@ -1,4 +1,4 @@
1
- import { validator } from '../../core/index.js';
1
+ import { validator, } from '../../core/index.js';
2
2
  /**
3
3
  *
4
4
  */
@@ -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.9.0",
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
- "validator": "^13.12.0",
11
- "tslib": "^2.6.3"
10
+ "tslib": "^2.7.0",
11
+ "validator": "^13.12.0"
12
12
  },
13
13
  "type": "module",
14
14
  "exports": {
@@ -1,4 +1,5 @@
1
- import { Context, Validator } from './index.js';
1
+ import type { Context } from './context.js';
2
+ import { type Validator } from './validator.js';
2
3
  /**
3
4
  * Forwards codec process to a sub codec. Useful for circular checks
4
5
  * @validator forwardRef
@@ -1,4 +1,4 @@
1
- import { ErrorIssue } from './types.js';
1
+ import { type ErrorIssue } from './types.js';
2
2
  export declare class ValidationError extends Error {
3
3
  issues: ErrorIssue[];
4
4
  constructor(issues: ErrorIssue[]);
@@ -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,4 +1,4 @@
1
- import { ValidationOptions } from '../../core/index.js';
1
+ import { type ValidationOptions } from '../../core/index.js';
2
2
  /**
3
3
  * Check if the string contains only letters (a-zA-Z).
4
4
  * @validator isAlpha
@@ -1,4 +1,4 @@
1
- import { ValidationOptions } from '../../core/index.js';
1
+ import { type ValidationOptions } from '../../core/index.js';
2
2
  /**
3
3
  * Check if the string contains ASCII chars only.
4
4
  * @validator isAscii
@@ -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,4 +1,4 @@
1
- import { ValidationOptions } from '../../core/index.js';
1
+ import { type ValidationOptions } from '../../core/index.js';
2
2
  /**
3
3
  * Validates if value is a BTC address.
4
4
  * @validator isBtcAddress
@@ -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
  /**
3
3
  * Check if the string represents a decimal number,
4
4
  * such as `0.1`, `.3`, `1.1`, `1.00003`, `4.0` etc.
@@ -1,4 +1,4 @@
1
- import { ValidationOptions } from '../../core/index.js';
1
+ import { type ValidationOptions } from '../../core/index.js';
2
2
  /**
3
3
  * Validates if value is an EAN (European Article Number)
4
4
  * @validator isEAN
@@ -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
  /**
3
3
  * Validates if value is a ETH (Ethereum) address.
4
4
  * @validator isETHAddress
@@ -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
  /**
3
3
  * Validates if value is a Hex Color
4
4
  * @validator isHexColor
@@ -1,4 +1,4 @@
1
- import { ValidationOptions } from '../../core/index.js';
1
+ import { type ValidationOptions } from '../../core/index.js';
2
2
  /**
3
3
  * Check if the string is a hexadecimal number.
4
4
  * @validator isHex
@@ -1,4 +1,4 @@
1
- import { ValidationOptions } from '../../core/index.js';
1
+ import { type ValidationOptions } from '../../core/index.js';
2
2
  /**
3
3
  * Validates if value is an IBAN (International Bank Account Number)
4
4
  * @validator isIBAN
@@ -1,4 +1,4 @@
1
- import { ValidationOptions } from '../../core/index.js';
1
+ import { type ValidationOptions } from '../../core/index.js';
2
2
  /**
3
3
  * Validates if value is an IP
4
4
  * @validator isIP
@@ -1,4 +1,4 @@
1
- import { ValidationOptions } from '../../core/index.js';
1
+ import { type ValidationOptions } from '../../core/index.js';
2
2
  export interface IsISSNOptions extends ValidationOptions {
3
3
  /**
4
4
  * If set to `true`, ISSNs with a lowercase `x` as the check digit are rejected.
@@ -1,4 +1,4 @@
1
- import { ValidationOptions } from '../../core/index.js';
1
+ import { type ValidationOptions } from '../../core/index.js';
2
2
  /**
3
3
  * Validates if value a valid JWT token
4
4
  * @validator isJWT
@@ -1,4 +1,4 @@
1
- import { ValidationOptions } from '../../core/index.js';
1
+ import { type ValidationOptions } from '../../core/index.js';
2
2
  /**
3
3
  * Validates if value a Lowercase string
4
4
  * @validator isLowercase
@@ -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
  export declare interface ObjectIdLike {
3
3
  id: string | Uint8Array;
4
4
  toHexString(): string;
@@ -1,4 +1,4 @@
1
- import { ValidationOptions } from '../../core/index.js';
1
+ import { type ValidationOptions } from '../../core/index.js';
2
2
  /**
3
3
  * Validates if value is a passport number
4
4
  * @validator isPassportNumber
@@ -1,4 +1,4 @@
1
- import { ValidationOptions } from '../../core/index.js';
1
+ import { type ValidationOptions } from '../../core/index.js';
2
2
  /**
3
3
  * Validates if value is a port number
4
4
  * @validator isPort
@@ -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 IsURLOptions extends ValidationOptions, validatorJS.IsURLOptions {
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
  /**
3
3
  * Validates if value is an "UUID".
4
4
  * @validator isUUID
@@ -1,4 +1,4 @@
1
- import { ValidationOptions } from '../../core/index.js';
1
+ import { type ValidationOptions } from '../../core/index.js';
2
2
  /**
3
3
  * Validates if value is an VAT number
4
4
  * @validator isVAT
@@ -1,4 +1,4 @@
1
- import { ValidationOptions } from '../../core/index.js';
1
+ import { type ValidationOptions } from '../../core/index.js';
2
2
  export interface IsRegExpOptions extends ValidationOptions {
3
3
  formatName?: string;
4
4
  }
@@ -1,4 +1,4 @@
1
- import { ValidationOptions } from '../../core/index.js';
1
+ import { type ValidationOptions } from '../../core/index.js';
2
2
  /**
3
3
  * Validates if value is not "undefined" nor "null"
4
4
  * @validator isDefined
@@ -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
  type RangeInput = number | bigint | Date | string;
3
3
  /**
4
4
  * Checks if value is between minValue and maxValue
@@ -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 { ValidationOptions } from '../../core/index.js';
1
+ import { type ValidationOptions } from '../../core/index.js';
2
2
  /**
3
3
  * Validates if value is "BigInt".
4
4
  * Converts input value to number if coerce option is set to 'true'.
@@ -1,4 +1,4 @@
1
- import { ValidationOptions } from '../../core/index.js';
1
+ import { type ValidationOptions } from '../../core/index.js';
2
2
  /**
3
3
  * Validates if value is "boolean".
4
4
  * Converts input value to boolean if coerce option is set to 'true'.
@@ -1,4 +1,4 @@
1
- import { ValidationOptions } from '../../core/index.js';
1
+ import { type ValidationOptions } from '../../core/index.js';
2
2
  /**
3
3
  * Validates if value is instance of "Date".
4
4
  * Converts input value to Date if coerce option is set to 'true'.
@@ -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 given value is one of enum values.
4
4
  * @validator isEnum
@@ -1,4 +1,4 @@
1
- import { ValidationOptions } from '../../core/index.js';
1
+ import { type ValidationOptions } from '../../core/index.js';
2
2
  /**
3
3
  * Validates if value is "integer".
4
4
  * Converts input value to integer number if coerce option is set to 'true'.
@@ -1,4 +1,4 @@
1
- import { ValidationOptions } from '../../core/index.js';
1
+ import { type ValidationOptions } from '../../core/index.js';
2
2
  /**
3
3
  * Validates if value is "null".
4
4
  * @validator isNull
@@ -1,4 +1,4 @@
1
- import { ValidationOptions } from '../../core/index.js';
1
+ import { type ValidationOptions } from '../../core/index.js';
2
2
  /**
3
3
  * Validates if value is "number".
4
4
  * Converts input value to number if coerce option is set to 'true'.
@@ -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 } from '../../core/index.js';
1
+ import { type ValidationOptions } from '../../core/index.js';
2
2
  /**
3
3
  * Validates if value is "string".
4
4
  * Converts input value to string if coerce option is set to 'true'.
@@ -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,4 +1,4 @@
1
- import { ValidationOptions } from '../../core/index.js';
1
+ import { type ValidationOptions } from '../../core/index.js';
2
2
  /**
3
3
  * Validates if value is "undefined"
4
4
  * @validator isUndefined
@@ -1,4 +1,4 @@
1
- import { ValidationOptions } from '../../core/index.js';
1
+ import { type ValidationOptions } from '../../core/index.js';
2
2
  /**
3
3
  * Validates if property exists
4
4
  * @validator exists
@@ -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,4 +1,4 @@
1
- import { ValidationOptions, Validator } from '../../core/index.js';
1
+ import { type ValidationOptions, type Validator } from '../../core/index.js';
2
2
  export interface PipeOptions extends ValidationOptions {
3
3
  returnIndex?: number;
4
4
  }
@@ -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
@@ -1,4 +1,4 @@
1
- import { Validator } from '../../core/index.js';
1
+ import { type Validator } from '../../core/index.js';
2
2
  /**
3
3
  *
4
4
  */