valgen 5.18.2 → 5.19.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 (208) hide show
  1. package/{types/constants.d.ts → constants.d.ts} +1 -0
  2. package/{esm/constants.js → constants.js} +1 -0
  3. package/{esm/core → core}/context.js +12 -2
  4. package/{esm/core → core}/validation-error.js +1 -1
  5. package/package.json +9 -25
  6. package/{types/rules → rules}/type-rules/is-date.d.ts +1 -0
  7. package/{esm/rules → rules}/type-rules/is-date.js +21 -10
  8. package/CHANGELOG.md +0 -384
  9. package/cjs/constants.js +0 -7
  10. package/cjs/core/constants.js +0 -5
  11. package/cjs/core/context.js +0 -74
  12. package/cjs/core/index.js +0 -9
  13. package/cjs/core/types.js +0 -2
  14. package/cjs/core/utilities.js +0 -30
  15. package/cjs/core/validation-error.js +0 -12
  16. package/cjs/core/validator.js +0 -71
  17. package/cjs/factories.js +0 -4
  18. package/cjs/helpers/object.utils.js +0 -18
  19. package/cjs/helpers/omit-undefined.js +0 -14
  20. package/cjs/helpers/string.utils.js +0 -6
  21. package/cjs/index.js +0 -129
  22. package/cjs/package.json +0 -3
  23. package/cjs/rules/format-rules/is-alpha.js +0 -30
  24. package/cjs/rules/format-rules/is-ascii.js +0 -17
  25. package/cjs/rules/format-rules/is-base64.js +0 -18
  26. package/cjs/rules/format-rules/is-btc-address.js +0 -18
  27. package/cjs/rules/format-rules/is-credit-card.js +0 -19
  28. package/cjs/rules/format-rules/is-decimal.js +0 -19
  29. package/cjs/rules/format-rules/is-ean.js +0 -17
  30. package/cjs/rules/format-rules/is-email.js +0 -66
  31. package/cjs/rules/format-rules/is-eth-address.js +0 -18
  32. package/cjs/rules/format-rules/is-fqdn.js +0 -21
  33. package/cjs/rules/format-rules/is-hash.js +0 -18
  34. package/cjs/rules/format-rules/is-hex-color.js +0 -18
  35. package/cjs/rules/format-rules/is-hex.js +0 -18
  36. package/cjs/rules/format-rules/is-iban.js +0 -29
  37. package/cjs/rules/format-rules/is-ip.js +0 -35
  38. package/cjs/rules/format-rules/is-issn.js +0 -21
  39. package/cjs/rules/format-rules/is-jwt.js +0 -17
  40. package/cjs/rules/format-rules/is-lowercase.js +0 -31
  41. package/cjs/rules/format-rules/is-mac-address.js +0 -24
  42. package/cjs/rules/format-rules/is-mobile-phone.js +0 -22
  43. package/cjs/rules/format-rules/is-object-id.js +0 -28
  44. package/cjs/rules/format-rules/is-passport-number.js +0 -19
  45. package/cjs/rules/format-rules/is-port.js +0 -22
  46. package/cjs/rules/format-rules/is-time.js +0 -51
  47. package/cjs/rules/format-rules/is-url.js +0 -20
  48. package/cjs/rules/format-rules/is-uuid.js +0 -20
  49. package/cjs/rules/format-rules/is-vat-number.js +0 -18
  50. package/cjs/rules/format-rules/matches.js +0 -22
  51. package/cjs/rules/index.js +0 -56
  52. package/cjs/rules/logical-rules/is-defined.js +0 -15
  53. package/cjs/rules/logical-rules/is-empty.js +0 -110
  54. package/cjs/rules/logical-rules/is-equal.js +0 -32
  55. package/cjs/rules/logical-rules/range.js +0 -175
  56. package/cjs/rules/type-rules/is-any.js +0 -10
  57. package/cjs/rules/type-rules/is-array.js +0 -45
  58. package/cjs/rules/type-rules/is-bigint.js +0 -21
  59. package/cjs/rules/type-rules/is-boolean.js +0 -31
  60. package/cjs/rules/type-rules/is-date.js +0 -180
  61. package/cjs/rules/type-rules/is-enum.js +0 -31
  62. package/cjs/rules/type-rules/is-integer.js +0 -30
  63. package/cjs/rules/type-rules/is-null.js +0 -54
  64. package/cjs/rules/type-rules/is-number.js +0 -27
  65. package/cjs/rules/type-rules/is-object.js +0 -113
  66. package/cjs/rules/type-rules/is-record.js +0 -42
  67. package/cjs/rules/type-rules/is-string.js +0 -81
  68. package/cjs/rules/type-rules/is-tuple.js +0 -38
  69. package/cjs/rules/type-rules/is-undefined.js +0 -17
  70. package/cjs/rules/utility-rules/all-of.js +0 -20
  71. package/cjs/rules/utility-rules/exists.js +0 -18
  72. package/cjs/rules/utility-rules/get-length.js +0 -29
  73. package/cjs/rules/utility-rules/one-of.js +0 -59
  74. package/cjs/rules/utility-rules/optional.js +0 -15
  75. package/cjs/rules/utility-rules/pipe.js +0 -28
  76. package/cjs/rules/utility-rules/required.js +0 -19
  77. package/cjs/tsconfig-build-cjs.tsbuildinfo +0 -1
  78. package/esm/package.json +0 -3
  79. package/esm/tsconfig-build-esm.tsbuildinfo +0 -1
  80. package/types/index.d.cts +0 -65
  81. /package/{types/core → core}/constants.d.ts +0 -0
  82. /package/{esm/core → core}/constants.js +0 -0
  83. /package/{types/core → core}/context.d.ts +0 -0
  84. /package/{types/core → core}/index.d.ts +0 -0
  85. /package/{esm/core → core}/index.js +0 -0
  86. /package/{types/core → core}/types.d.ts +0 -0
  87. /package/{esm/core → core}/types.js +0 -0
  88. /package/{types/core → core}/utilities.d.ts +0 -0
  89. /package/{esm/core → core}/utilities.js +0 -0
  90. /package/{types/core → core}/validation-error.d.ts +0 -0
  91. /package/{types/core → core}/validator.d.ts +0 -0
  92. /package/{esm/core → core}/validator.js +0 -0
  93. /package/{types/factories.d.ts → factories.d.ts} +0 -0
  94. /package/{esm/factories.js → factories.js} +0 -0
  95. /package/{types/helpers → helpers}/object.utils.d.ts +0 -0
  96. /package/{esm/helpers → helpers}/object.utils.js +0 -0
  97. /package/{types/helpers → helpers}/omit-undefined.d.ts +0 -0
  98. /package/{esm/helpers → helpers}/omit-undefined.js +0 -0
  99. /package/{types/helpers → helpers}/string.utils.d.ts +0 -0
  100. /package/{esm/helpers → helpers}/string.utils.js +0 -0
  101. /package/{types/index.d.ts → index.d.ts} +0 -0
  102. /package/{esm/index.js → index.js} +0 -0
  103. /package/{types/rules → rules}/format-rules/is-alpha.d.ts +0 -0
  104. /package/{esm/rules → rules}/format-rules/is-alpha.js +0 -0
  105. /package/{types/rules → rules}/format-rules/is-ascii.d.ts +0 -0
  106. /package/{esm/rules → rules}/format-rules/is-ascii.js +0 -0
  107. /package/{types/rules → rules}/format-rules/is-base64.d.ts +0 -0
  108. /package/{esm/rules → rules}/format-rules/is-base64.js +0 -0
  109. /package/{types/rules → rules}/format-rules/is-btc-address.d.ts +0 -0
  110. /package/{esm/rules → rules}/format-rules/is-btc-address.js +0 -0
  111. /package/{types/rules → rules}/format-rules/is-credit-card.d.ts +0 -0
  112. /package/{esm/rules → rules}/format-rules/is-credit-card.js +0 -0
  113. /package/{types/rules → rules}/format-rules/is-decimal.d.ts +0 -0
  114. /package/{esm/rules → rules}/format-rules/is-decimal.js +0 -0
  115. /package/{types/rules → rules}/format-rules/is-ean.d.ts +0 -0
  116. /package/{esm/rules → rules}/format-rules/is-ean.js +0 -0
  117. /package/{types/rules → rules}/format-rules/is-email.d.ts +0 -0
  118. /package/{esm/rules → rules}/format-rules/is-email.js +0 -0
  119. /package/{types/rules → rules}/format-rules/is-eth-address.d.ts +0 -0
  120. /package/{esm/rules → rules}/format-rules/is-eth-address.js +0 -0
  121. /package/{types/rules → rules}/format-rules/is-fqdn.d.ts +0 -0
  122. /package/{esm/rules → rules}/format-rules/is-fqdn.js +0 -0
  123. /package/{types/rules → rules}/format-rules/is-hash.d.ts +0 -0
  124. /package/{esm/rules → rules}/format-rules/is-hash.js +0 -0
  125. /package/{types/rules → rules}/format-rules/is-hex-color.d.ts +0 -0
  126. /package/{esm/rules → rules}/format-rules/is-hex-color.js +0 -0
  127. /package/{types/rules → rules}/format-rules/is-hex.d.ts +0 -0
  128. /package/{esm/rules → rules}/format-rules/is-hex.js +0 -0
  129. /package/{types/rules → rules}/format-rules/is-iban.d.ts +0 -0
  130. /package/{esm/rules → rules}/format-rules/is-iban.js +0 -0
  131. /package/{types/rules → rules}/format-rules/is-ip.d.ts +0 -0
  132. /package/{esm/rules → rules}/format-rules/is-ip.js +0 -0
  133. /package/{types/rules → rules}/format-rules/is-issn.d.ts +0 -0
  134. /package/{esm/rules → rules}/format-rules/is-issn.js +0 -0
  135. /package/{types/rules → rules}/format-rules/is-jwt.d.ts +0 -0
  136. /package/{esm/rules → rules}/format-rules/is-jwt.js +0 -0
  137. /package/{types/rules → rules}/format-rules/is-lowercase.d.ts +0 -0
  138. /package/{esm/rules → rules}/format-rules/is-lowercase.js +0 -0
  139. /package/{types/rules → rules}/format-rules/is-mac-address.d.ts +0 -0
  140. /package/{esm/rules → rules}/format-rules/is-mac-address.js +0 -0
  141. /package/{types/rules → rules}/format-rules/is-mobile-phone.d.ts +0 -0
  142. /package/{esm/rules → rules}/format-rules/is-mobile-phone.js +0 -0
  143. /package/{types/rules → rules}/format-rules/is-object-id.d.ts +0 -0
  144. /package/{esm/rules → rules}/format-rules/is-object-id.js +0 -0
  145. /package/{types/rules → rules}/format-rules/is-passport-number.d.ts +0 -0
  146. /package/{esm/rules → rules}/format-rules/is-passport-number.js +0 -0
  147. /package/{types/rules → rules}/format-rules/is-port.d.ts +0 -0
  148. /package/{esm/rules → rules}/format-rules/is-port.js +0 -0
  149. /package/{types/rules → rules}/format-rules/is-time.d.ts +0 -0
  150. /package/{esm/rules → rules}/format-rules/is-time.js +0 -0
  151. /package/{types/rules → rules}/format-rules/is-url.d.ts +0 -0
  152. /package/{esm/rules → rules}/format-rules/is-url.js +0 -0
  153. /package/{types/rules → rules}/format-rules/is-uuid.d.ts +0 -0
  154. /package/{esm/rules → rules}/format-rules/is-uuid.js +0 -0
  155. /package/{types/rules → rules}/format-rules/is-vat-number.d.ts +0 -0
  156. /package/{esm/rules → rules}/format-rules/is-vat-number.js +0 -0
  157. /package/{types/rules → rules}/format-rules/matches.d.ts +0 -0
  158. /package/{esm/rules → rules}/format-rules/matches.js +0 -0
  159. /package/{types/rules → rules}/index.d.ts +0 -0
  160. /package/{esm/rules → rules}/index.js +0 -0
  161. /package/{types/rules → rules}/logical-rules/is-defined.d.ts +0 -0
  162. /package/{esm/rules → rules}/logical-rules/is-defined.js +0 -0
  163. /package/{types/rules → rules}/logical-rules/is-empty.d.ts +0 -0
  164. /package/{esm/rules → rules}/logical-rules/is-empty.js +0 -0
  165. /package/{types/rules → rules}/logical-rules/is-equal.d.ts +0 -0
  166. /package/{esm/rules → rules}/logical-rules/is-equal.js +0 -0
  167. /package/{types/rules → rules}/logical-rules/range.d.ts +0 -0
  168. /package/{esm/rules → rules}/logical-rules/range.js +0 -0
  169. /package/{types/rules → rules}/type-rules/is-any.d.ts +0 -0
  170. /package/{esm/rules → rules}/type-rules/is-any.js +0 -0
  171. /package/{types/rules → rules}/type-rules/is-array.d.ts +0 -0
  172. /package/{esm/rules → rules}/type-rules/is-array.js +0 -0
  173. /package/{types/rules → rules}/type-rules/is-bigint.d.ts +0 -0
  174. /package/{esm/rules → rules}/type-rules/is-bigint.js +0 -0
  175. /package/{types/rules → rules}/type-rules/is-boolean.d.ts +0 -0
  176. /package/{esm/rules → rules}/type-rules/is-boolean.js +0 -0
  177. /package/{types/rules → rules}/type-rules/is-enum.d.ts +0 -0
  178. /package/{esm/rules → rules}/type-rules/is-enum.js +0 -0
  179. /package/{types/rules → rules}/type-rules/is-integer.d.ts +0 -0
  180. /package/{esm/rules → rules}/type-rules/is-integer.js +0 -0
  181. /package/{types/rules → rules}/type-rules/is-null.d.ts +0 -0
  182. /package/{esm/rules → rules}/type-rules/is-null.js +0 -0
  183. /package/{types/rules → rules}/type-rules/is-number.d.ts +0 -0
  184. /package/{esm/rules → rules}/type-rules/is-number.js +0 -0
  185. /package/{types/rules → rules}/type-rules/is-object.d.ts +0 -0
  186. /package/{esm/rules → rules}/type-rules/is-object.js +0 -0
  187. /package/{types/rules → rules}/type-rules/is-record.d.ts +0 -0
  188. /package/{esm/rules → rules}/type-rules/is-record.js +0 -0
  189. /package/{types/rules → rules}/type-rules/is-string.d.ts +0 -0
  190. /package/{esm/rules → rules}/type-rules/is-string.js +0 -0
  191. /package/{types/rules → rules}/type-rules/is-tuple.d.ts +0 -0
  192. /package/{esm/rules → rules}/type-rules/is-tuple.js +0 -0
  193. /package/{types/rules → rules}/type-rules/is-undefined.d.ts +0 -0
  194. /package/{esm/rules → rules}/type-rules/is-undefined.js +0 -0
  195. /package/{types/rules → rules}/utility-rules/all-of.d.ts +0 -0
  196. /package/{esm/rules → rules}/utility-rules/all-of.js +0 -0
  197. /package/{types/rules → rules}/utility-rules/exists.d.ts +0 -0
  198. /package/{esm/rules → rules}/utility-rules/exists.js +0 -0
  199. /package/{types/rules → rules}/utility-rules/get-length.d.ts +0 -0
  200. /package/{esm/rules → rules}/utility-rules/get-length.js +0 -0
  201. /package/{types/rules → rules}/utility-rules/one-of.d.ts +0 -0
  202. /package/{esm/rules → rules}/utility-rules/one-of.js +0 -0
  203. /package/{types/rules → rules}/utility-rules/optional.d.ts +0 -0
  204. /package/{esm/rules → rules}/utility-rules/optional.js +0 -0
  205. /package/{types/rules → rules}/utility-rules/pipe.d.ts +0 -0
  206. /package/{esm/rules → rules}/utility-rules/pipe.js +0 -0
  207. /package/{types/rules → rules}/utility-rules/required.d.ts +0 -0
  208. /package/{esm/rules → rules}/utility-rules/required.js +0 -0
@@ -1,3 +1,4 @@
1
+ export declare const version = "1";
1
2
  export declare const postValidation: unique symbol;
2
3
  export declare const preValidation: unique symbol;
3
4
  export declare const VALIDATE_METADATA: unique symbol;
@@ -1,3 +1,4 @@
1
+ export const version = '5.19.0';
1
2
  export const postValidation = Symbol('postValidation');
2
3
  export const preValidation = Symbol('preValidation');
3
4
  export const VALIDATE_METADATA = Symbol('VALIDATE_METADATA');
@@ -3,9 +3,19 @@ import { ValidationError } from './validation-error.js';
3
3
  const VARIABLE_REPLACE_PATTERN = /{{([^}]*)}}/g;
4
4
  const OPTIONAL_VAR_PATTERN = /^([^?]+)(?:\||(.*))?$/;
5
5
  export class Context {
6
+ isRoot = true;
7
+ errors = [];
8
+ maxErrors;
9
+ onFail;
10
+ coerce;
11
+ root;
12
+ location;
13
+ scope;
14
+ context;
15
+ property;
16
+ index;
17
+ label;
6
18
  constructor(options) {
7
- this.isRoot = true;
8
- this.errors = [];
9
19
  Object.assign(this, options);
10
20
  }
11
21
  fail(rule, message, value, details) {
@@ -1,8 +1,8 @@
1
1
  export class ValidationError extends Error {
2
+ issues = [];
2
3
  constructor(issues) {
3
4
  super(issues[0].message +
4
5
  (issues[0].location ? `\n at ${issues[0].location}` : ''));
5
- this.issues = [];
6
6
  this.issues = issues;
7
7
  }
8
8
  }
package/package.json CHANGED
@@ -1,34 +1,29 @@
1
1
  {
2
2
  "name": "valgen",
3
3
  "description": "Fast runtime type validator, converter and io (encoding/decoding) library",
4
- "version": "5.18.2",
4
+ "version": "5.19.0",
5
5
  "author": "Panates",
6
6
  "license": "MIT",
7
7
  "dependencies": {
8
- "@browsery/validator": "^13.12.0-r3",
8
+ "@browsery/validator": "^13.15.15",
9
9
  "date-fns": "^4.1.0",
10
10
  "reflect-metadata": "^0.2.2",
11
11
  "ts-gems": "^3.11.3",
12
12
  "tslib": "^2.8.1"
13
13
  },
14
14
  "type": "module",
15
+ "module": "./index.js",
16
+ "types": "./index.d.ts",
15
17
  "exports": {
16
18
  ".": {
17
- "import": {
18
- "types": "./types/index.d.ts",
19
- "default": "./esm/index.js"
20
- },
21
- "require": {
22
- "types": "./types/index.d.cts",
23
- "default": "./cjs/index.js"
24
- },
25
- "default": "./esm/index.js"
19
+ "types": "./index.d.ts",
20
+ "default": "./index.js"
26
21
  },
27
22
  "./package.json": "./package.json"
28
23
  },
29
- "main": "./cjs/index.js",
30
- "module": "./esm/index.js",
31
- "types": "./types/index.d.ts",
24
+ "engines": {
25
+ "node": ">=20.0"
26
+ },
32
27
  "contributors": [
33
28
  "Eray Hanoglu <e.hanoglu@panates.com>"
34
29
  ],
@@ -36,17 +31,6 @@
36
31
  "type": "git",
37
32
  "url": "https://github.com/panates/valgen.git"
38
33
  },
39
- "engines": {
40
- "node": ">= 16.0"
41
- },
42
- "files": [
43
- "cjs/",
44
- "esm/",
45
- "types/",
46
- "LICENSE",
47
- "README.md",
48
- "CHANGELOG.md"
49
- ],
50
34
  "keywords": [
51
35
  "validate",
52
36
  "validation",
@@ -13,6 +13,7 @@ export interface IsDateStringOptions extends ValidationOptions {
13
13
  precisionMin?: Precision;
14
14
  precisionMax?: Precision;
15
15
  trim?: Precision;
16
+ timeZone?: boolean | number;
16
17
  }
17
18
  /**
18
19
  * Validates if value is DFS (date formatted string).
@@ -37,10 +37,11 @@ export function isDate(options) {
37
37
  * @validator isDateString
38
38
  */
39
39
  export function isDateString(options) {
40
- const precisionMin = options?.precisionMin || 'minutes';
40
+ const trimIdx = PRECISION_INDEX[options?.trim || 'tz'] || 9;
41
+ const precisionMin = options?.precisionMin || options?.trim || 'minutes';
41
42
  const precisionMax = options?.precisionMax || 'tz';
42
43
  const precisionMaxIdx = PRECISION_INDEX[precisionMax] || 9;
43
- const precisionMinIdx = Math.min(precisionMaxIdx, PRECISION_INDEX[precisionMin] || 6);
44
+ const precisionMinIdx = Math.min(trimIdx, precisionMaxIdx, PRECISION_INDEX[precisionMin] || 6);
44
45
  return validator('isDateString', (input, context, _this) => {
45
46
  const coerce = options?.coerce ?? context.coerce;
46
47
  const parsed = coerceDateString(input, options?.trim);
@@ -62,8 +63,9 @@ export function isDateString(options) {
62
63
  const DATE_PATTERN = /^(\d{4})(?:-(0[0-9]|1[0-2]))?(?:-([0-2][0-9]|3[0-1]))?(?:[T ](?:([0-1][0-9]|2[0-4]):([0-5][0-9])(?::([0-5][0-9]))?(?:\.(\d{0,6}))?)?((?:[+-](0[0-9]|1[0-2])(?::(\d{2}))?)|Z)?)?$/;
63
64
  const DATE_PATTERN2 = /^(\d{4,14})(?:\.(\d{1,6}))?(?:(?:([+-])(0[0-9]|1[0-2])(\d{2})?)|Z)?$/;
64
65
  function coerceDateString(input, precision) {
66
+ const precisionIndex = (precision ? PRECISION_INDEX[precision] : 9) || 9;
65
67
  let dateParts;
66
- let outPrecision = 0;
68
+ let detectedPrecision = 0;
67
69
  if (input instanceof Date || typeof input === 'number') {
68
70
  const d = typeof input === 'number' ? new Date(input) : input;
69
71
  dateParts = [
@@ -74,8 +76,18 @@ function coerceDateString(input, precision) {
74
76
  String(d.getMinutes()).padStart(2, '0'),
75
77
  String(d.getSeconds()).padStart(2, '0'),
76
78
  ];
77
- if (d.getMilliseconds() > 0)
79
+ if (precisionIndex >= 7 && d.getMilliseconds() > 0)
78
80
  dateParts.push(String(d.getMilliseconds()).padStart(3, '0'));
81
+ if (precisionIndex >= 8) {
82
+ const tzOffset = d.getTimezoneOffset();
83
+ const tz = tzOffset > 0
84
+ ? '-'
85
+ : '+' +
86
+ String(Math.floor(Math.abs(tzOffset) / 60)).padStart(2, '0') +
87
+ ':' +
88
+ String(Math.abs(tzOffset) % 60).padStart(2, '0');
89
+ dateParts.push(tz);
90
+ }
79
91
  }
80
92
  else if (typeof input === 'string') {
81
93
  const d = datefns.parseISO(input);
@@ -102,10 +114,9 @@ function coerceDateString(input, precision) {
102
114
  }
103
115
  if (!dateParts)
104
116
  return;
105
- outPrecision = dateParts.findIndex(v => !v);
106
- if (outPrecision === -1)
107
- outPrecision = dateParts.length;
108
- const precisionIndex = (precision ? PRECISION_INDEX[precision] : 9) || 9;
117
+ detectedPrecision = dateParts.findIndex(v => !v);
118
+ if (detectedPrecision === -1)
119
+ detectedPrecision = Math.min(dateParts.length, 8);
109
120
  let value = dateParts[0] || '0000';
110
121
  if (precisionIndex > 1)
111
122
  value += '-' + (dateParts[1] || '01');
@@ -117,13 +128,13 @@ function coerceDateString(input, precision) {
117
128
  value += ':' + (dateParts[4] || '00');
118
129
  if (precisionIndex > 5)
119
130
  value += ':' + (dateParts[5] || '00');
120
- if (precisionIndex > 5)
131
+ if (precisionIndex > 6)
121
132
  value += dateParts[6] ? '.' + dateParts[6] : '';
122
133
  if (precisionIndex > 7)
123
134
  value += dateParts[7] || '';
124
135
  return {
125
136
  value,
126
- precision: outPrecision || 8,
137
+ precision: detectedPrecision || 8,
127
138
  };
128
139
  }
129
140
  const PRECISION_INDEX = {
package/CHANGELOG.md DELETED
@@ -1,384 +0,0 @@
1
- ## Changelog
2
-
3
- ### [v5.18.2](https://github.com/panates/valgen/compare/v5.18.1...v5.18.2) -
4
-
5
- #### 🛠 Refactoring and Updates
6
-
7
- - refactor: Set precision of toDateString() to "day" @Eray Hanoğlu
8
-
9
- ### [v5.18.1](https://github.com/panates/valgen/compare/v5.18.0...v5.18.1) - 27 August 2025
10
-
11
- #### 🪲 Fixes
12
-
13
- - fix: Increased ms precision @Eray Hanoğlu
14
-
15
- ### [v5.18.0](https://github.com/panates/valgen/compare/v5.17.3...v5.18.0) - 31 July 2025
16
-
17
- #### 🚀 New Features
18
-
19
- - feat: isTime accept Date instance @Eray Hanoğlu
20
-
21
- #### 🪲 Fixes
22
-
23
- - fix: Minor fix in isDate rule @Eray Hanoğlu
24
-
25
- ### [v5.17.3](https://github.com/panates/valgen/compare/v5.17.2...v5.17.3) - 30 July 2025
26
-
27
- #### 🚀 New Features
28
-
29
- - feat: isDate can parse date string without signs @Eray Hanoğlu
30
-
31
- ### [v5.17.2](https://github.com/panates/valgen/compare/v5.17.1...v5.17.2) - 29 July 2025
32
-
33
- #### 🛠 Refactoring and Updates
34
-
35
- - refactor: Minor date rule optimization @Eray Hanoğlu
36
-
37
- ### [v5.17.1](https://github.com/panates/valgen/compare/v5.17.0...v5.17.1) - 24 July 2025
38
-
39
- #### 🪲 Fixes
40
-
41
- - fix: isDate milliseconds padding @Eray Hanoğlu
42
-
43
- ### [v5.17.0](https://github.com/panates/valgen/compare/v5.16.0...v5.17.0) - 24 July 2025
44
-
45
- #### 🪲 Fixes
46
-
47
- - refactor: Refactored isDate and isDateString validation rules @Eray Hanoğlu
48
-
49
- #### 🛠 Refactoring and Updates
50
-
51
- - refactor: Refactored isDate and isDateString validation rules @Eray Hanoğlu
52
-
53
- ### [v5.16.0](https://github.com/panates/valgen/compare/v5.15.4...v5.16.0) - 16 July 2025
54
-
55
- #### 🛠 Refactoring and Updates
56
-
57
- - refactor: Refactored isDate and isDateString validation rules @Eray Hanoğlu
58
-
59
- ### [v5.15.4](https://github.com/panates/valgen/compare/v5.15.3...v5.15.4) - 11 July 2025
60
-
61
- #### 🛠 Refactoring and Updates
62
-
63
- - refactor: Exported default isTime rule @Eray Hanoğlu
64
-
65
- ### [v5.15.3](https://github.com/panates/valgen/compare/v5.15.2...v5.15.3) - 20 June 2025
66
-
67
- #### 🚀 New Features
68
-
69
- - feat: Adde default value option to "required" rule @Eray Hanoğlu
70
-
71
- ### [v5.15.2](https://github.com/panates/valgen/compare/v5.15.1...v5.15.2) - 27 May 2025
72
-
73
- #### 🛠 Refactoring and Updates
74
-
75
- - refactor: Refactored isGte, isGt, isLte, isLt typing @Eray Hanoğlu
76
-
77
- ### [v5.15.1](https://github.com/panates/valgen/compare/v5.15.0...v5.15.1) - 27 May 2025
78
-
79
- #### 🚀 New Features
80
-
81
- - feat: Added isTime rule @Eray Hanoğlu
82
-
83
- #### 🪲 Fixes
84
-
85
- - fix: Error message fix @Eray Hanoğlu
86
-
87
- #### 🛠 Refactoring and Updates
88
-
89
- - refactor: Removed path filter @Eray Hanoğlu
90
-
91
- ### [v5.15.0](https://github.com/panates/valgen/compare/v5.14.1...v5.15.0) - 24 April 2025
92
-
93
- #### 🚀 New Features
94
-
95
- - feat: Added discriminator validation to oneOf rule @Eray Hanoğlu
96
- - feat: Added isEqual, isNotEqual rules @Eray Hanoğlu
97
-
98
- #### 🛠 Refactoring and Updates
99
-
100
- - refactor: Fixes and improvements @Eray Hanoğlu
101
- - refactor: Removed union rule. Use oneOf rule instead @Eray Hanoğlu
102
-
103
- ### [v5.14.1](https://github.com/panates/valgen/compare/v5.14.0...v5.14.1) - 21 April 2025
104
-
105
- #### 🪲 Fixes
106
-
107
- - fix: Fixed validation issue while using silent mode @Eray Hanoğlu
108
-
109
- #### 💬 General Changes
110
-
111
- - dev: Moved from nyc to c8 @Eray Hanoğlu
112
- - ci: Added workflows @Eray Hanoğlu
113
- - dev: Fixed nycrc file @Eray Hanoğlu
114
- - dev: Added publishConfig @Eray Hanoğlu
115
- - dev: Fixed nycrc file @Eray Hanoğlu
116
- - dev: Fixed paths @Eray Hanoğlu
117
- - dev: Fixed nycrc file @Eray Hanoğlu
118
- - dev: Fixed nycrc file @Eray Hanoğlu
119
- - dev: Added qc script @Eray Hanoğlu
120
-
121
- ### [v5.14.0](https://github.com/panates/valgen/compare/v5.13.4...v5.14.0) - 30 March 2025
122
-
123
- #### 🛠 Refactoring and Updates
124
-
125
- - refactor: Moved from jest to mocha @Eray Hanoğlu
126
-
127
- ### [v5.13.4](https://github.com/panates/valgen/compare/v5.13.3...v5.13.4) - 26 March 2025
128
-
129
- #### 🪲 Fixes
130
-
131
- - fix: isNotEmpty do not work for number and boolean types @Eray Hanoğlu
132
-
133
- ### [v5.13.3](https://github.com/panates/valgen/compare/v5.13.2...v5.13.3) - 17 March 2025
134
-
135
- #### 🪲 Fixes
136
-
137
- - fix: isEmpty and isNotEmpty rules adds error issue twice @Eray Hanoğlu
138
-
139
- ### [v5.13.2](https://github.com/panates/valgen/compare/v5.13.1...v5.13.2) - 15 March 2025
140
-
141
- #### 🪲 Fixes
142
-
143
- - fix: Fixed ignoring pipe validators if context.errors has items. @Eray Hanoğlu
144
-
145
- ### [v5.13.1](https://github.com/panates/valgen/compare/v5.13.0...v5.13.1) - 14 March 2025
146
-
147
- #### 🪲 Fixes
148
-
149
- - fix: Fixed validation of Date, Buffer and ArrayBuffer objects of isEmpty and isNotEmpty rules @Eray Hanoğlu
150
- - fix: Fixed validation of Date, Buffer and ArrayBuffer objects of isEmpty and isNotEmpty rules @Eray Hanoğlu
151
-
152
- ### [v5.13.0](https://github.com/panates/valgen/compare/v5.12.0...v5.13.0) - 3 February 2025
153
-
154
- #### 🛠 Refactoring and Updates
155
-
156
- - refactor: Updated dependencies @Eray Hanoğlu
157
- - refactor: Changed error messages to "positive sentences" @Eray Hanoğlu
158
-
159
- #### 💬 General Changes
160
-
161
- - dev: Fixed ts config @Eray Hanoğlu
162
- - dev: Added missing script @Eray Hanoğlu
163
-
164
- ### [v5.12.0](https://github.com/panates/valgen/compare/v5.11.0...v5.12.0) - 4 November 2024
165
-
166
- #### 🛠 Refactoring and Updates
167
-
168
- - refactor: Move from 'validator' library to "@browsery/validator" for ESM compatibility @Eray Hanoğlu
169
-
170
- ### [v5.11.0](https://github.com/panates/valgen/compare/v5.10.0...v5.11.0) - 4 November 2024
171
-
172
- #### 💬 General Changes
173
-
174
- - nit: Updated dependencies @Eray Hanoğlu
175
-
176
- ### [v5.10.0](https://github.com/panates/valgen/compare/v5.9.0...v5.10.0) - 14 September 2024
177
-
178
- #### 💬 General Changes
179
-
180
- - fixed: Circular imports @Eray Hanoğlu
181
-
182
- ### [v5.9.0](https://github.com/panates/valgen/compare/v5.8.2...v5.9.0) - 20 August 2024
183
-
184
- #### 💬 General Changes
185
-
186
- - Fixed compatibility for "Node16" and "NodeNext" moduleResolution options @Eray Hanoğlu
187
-
188
- ### [v5.8.2](https://github.com/panates/valgen/compare/v5.8.1...v5.8.2) - 12 August 2024
189
-
190
- #### 💬 General Changes
191
-
192
- - Applied publint to check package.json @Eray Hanoğlu
193
-
194
- ### [v5.8.1](https://github.com/panates/valgen/compare/v5.8.0...v5.8.1) - 12 August 2024
195
-
196
- #### 💬 General Changes
197
-
198
- - Applied publint to check package.json @Eray Hanoğlu
199
-
200
- ### [v5.8.0](https://github.com/panates/valgen/compare/v5.7.0...v5.8.0) - 12 August 2024
201
-
202
- #### 💬 General Changes
203
-
204
- - Rollback to ES2020 @Eray Hanoğlu
205
-
206
- ### [v5.7.0](https://github.com/panates/valgen/compare/v5.6.0...v5.7.0) - 9 August 2024
207
-
208
- #### 💬 General Changes
209
-
210
- - Made ready for Node16 moduleResolution @Eray Hanoğlu
211
-
212
- ### [v5.6.0](https://github.com/panates/valgen/compare/v5.5.0...v5.6.0) - 14 July 2024
213
-
214
- #### 💬 General Changes
215
-
216
- - Added isNotNull and isNotNullish rules @Eray Hanoğlu
217
- - Added isNotNull and isNotNullish rules @Eray Hanoğlu
218
-
219
- ### [v5.5.0](https://github.com/panates/valgen/compare/v5.4.1...v5.5.0) - 14 July 2024
220
-
221
- #### 💬 General Changes
222
-
223
- - Moved eslint config to @panates/eslint-config @Eray Hanoğlu
224
- - Changed error message @Eray Hanoğlu
225
- - Removed coercing of isNull and isNullish rules @Eray Hanoğlu
226
- - Now pipe can return original input value when returnIndex = -1 @Eray Hanoğlu
227
-
228
- ### [v5.4.1](https://github.com/panates/valgen/compare/v5.4.0...v5.4.1) - 18 May 2024
229
-
230
- #### 💬 General Changes
231
-
232
- - Exposed toBigint @Eray Hanoğlu
233
-
234
- ### [v5.4.0](https://github.com/panates/valgen/compare/v5.3.2...v5.4.0) - 18 May 2024
235
-
236
- #### 💬 General Changes
237
-
238
- - Added returnIndex to pipe() @Eray Hanoğlu
239
- - Updated circleci config @Eray Hanoğlu
240
-
241
- ### [v5.3.2](https://github.com/panates/valgen/compare/v5.3.1...v5.3.2) - 18 May 2024
242
-
243
- #### 💬 General Changes
244
-
245
- - Updated dependencies @Eray Hanoğlu
246
- - Fixed coveralls token @Eray Hanoğlu
247
-
248
- ### [v5.3.1](https://github.com/panates/valgen/compare/v5.3.0...v5.3.1) - 18 May 2024
249
-
250
- #### 💬 General Changes
251
-
252
- - Reorganized many rules @Eray Hanoğlu
253
- - Updated code documentation @Eray Hanoğlu
254
- - Fixed rule name @Eray Hanoğlu
255
-
256
- ### [v5.3.0](https://github.com/panates/valgen/compare/v5.2.2...v5.3.0) - 6 May 2024
257
-
258
- #### 💬 General Changes
259
-
260
- - Added validation generation option to enable coercing by default. @Eray Hanoğlu
261
-
262
- ### [v5.2.2](https://github.com/panates/valgen/compare/v5.2.1...v5.2.2) - 29 March 2024
263
-
264
- #### 💬 General Changes
265
-
266
- - Updated dependencies @Eray Hanoğlu
267
- - Updated dependencies @Eray Hanoğlu
268
-
269
- ### [v5.2.1](https://github.com/panates/valgen/compare/v5.2.0...v5.2.1) - 27 March 2024
270
-
271
- #### 💬 General Changes
272
-
273
- - Updated dependencies @Eray Hanoğlu
274
-
275
- ### [v5.2.0](https://github.com/panates/valgen/compare/v5.1.0...v5.2.0) - 4 January 2024
276
-
277
- #### 💬 General Changes
278
-
279
- - Now validator options persist in context @Eray Hanoğlu
280
-
281
- ### [v5.1.0](https://github.com/panates/valgen/compare/v5.0.1...v5.1.0) - 23 December 2023
282
-
283
- #### 💬 General Changes
284
-
285
- - Moved from "dayjs" to "date-fns" @Eray Hanoğlu
286
-
287
- ### [v5.0.1](https://github.com/panates/valgen/compare/v5.0.0...v5.0.1) - 23 December 2023
288
-
289
- #### 💬 General Changes
290
-
291
- - Added new rules @Eray Hanoğlu
292
- - Moved all validator factories into "factories" namespace, @Eray Hanoğlu
293
-
294
- ## [v5.0.0](https://github.com/panates/valgen/compare/v4.3.2...v5.0.0) - 21 December 2023
295
-
296
- #### 💬 General Changes
297
-
298
- - Moved all validator factories into "factories" namespace, @Eray Hanoğlu
299
-
300
- ### [v4.3.2](https://github.com/panates/valgen/compare/v4.3.1...v4.3.2) - 8 December 2023
301
-
302
- #### 💬 General Changes
303
-
304
- - Updated dependenices @Eray Hanoğlu
305
- - Pass "_this" parameter to preValidation and postValidation methods @Eray Hanoğlu
306
-
307
- ### [v4.3.1](https://github.com/panates/valgen/compare/v4.3.0...v4.3.1) - 4 December 2023
308
-
309
- #### 💬 General Changes
310
-
311
- - Made preValidation and postValidation static @Eray Hanoğlu
312
-
313
- ### [v4.3.0](https://github.com/panates/valgen/compare/v4.2.5...v4.3.0) - 2 December 2023
314
-
315
- #### 💬 General Changes
316
-
317
- - Updated dependencies @Eray Hanoğlu
318
- - Added [preValidation] and [postValidation] to isObject rule @Eray Hanoğlu
319
-
320
- ### [v4.2.5](https://github.com/panates/valgen/compare/v4.2.4...v4.2.5) - 27 November 2023
321
-
322
- #### 💬 General Changes
323
-
324
- - Fixed isArray error location property. @Eray Hanoğlu
325
-
326
- ### [v4.2.4](https://github.com/panates/valgen/compare/v4.2.3...v4.2.4) - 20 November 2023
327
-
328
- #### 💬 General Changes
329
-
330
- - Added json parsing feature to isObject validator @Eray Hanoğlu
331
-
332
- ### [v4.2.3](https://github.com/panates/valgen/compare/v4.2.2...v4.2.3) - 20 November 2023
333
-
334
- #### 💬 General Changes
335
-
336
- - Optimized error messages @Eray Hanoğlu
337
-
338
- ### [v4.2.2](https://github.com/panates/valgen/compare/v4.2.1...v4.2.2) - 15 November 2023
339
-
340
- #### 💬 General Changes
341
-
342
- - Changed "trim" option @Eray Hanoğlu
343
-
344
- ### [v4.2.1](https://github.com/panates/valgen/compare/v4.2.0...v4.2.1) - 15 November 2023
345
-
346
- #### 💬 General Changes
347
-
348
- - Fixed generating invalid date string @Eray Hanoğlu
349
-
350
- ### [v4.2.0](https://github.com/panates/valgen/compare/v4.1.0...v4.2.0) - 15 November 2023
351
-
352
- #### 💬 General Changes
353
-
354
- - Removed "format" option and added "precision" option to isDate validator @Eray Hanoğlu
355
- - Added test for "label" option @Eray Hanoğlu
356
-
357
- ### [v4.1.0](https://github.com/panates/valgen/compare/v4.0.1...v4.1.0) - 31 October 2023
358
-
359
- #### 💬 General Changes
360
-
361
- - Updated validation messages. @Eray Hanoğlu
362
-
363
- ### [v4.0.1](https://github.com/panates/valgen/compare/v4.0.0...v4.0.1) - 24 October 2023
364
-
365
- #### 💬 General Changes
366
-
367
- - Added "coerce" option to isNull and isUndefined rules @Eray Hanoğlu
368
-
369
- ## [v4.0.0](https://github.com/panates/valgen/compare/v3.2.1...v4.0.0) - 17 August 2023
370
-
371
- #### 💬 General Changes
372
-
373
- - Initial release of v4.0.0-alpha.1 @Eray Hanoğlu
374
- - Implemented all initial validators and tests @Eray Hanoğlu
375
- - Updated dependencies @Eray Hanoğlu
376
- - Better error handling @Eray Hanoğlu
377
- - Updated deps @Eray Hanoğlu
378
- - Added isBigint validator @Eray Hanoğlu
379
- - Fixed isObject coerce issue @Eray Hanoğlu
380
- - Improved isDateString @Eray Hanoğlu
381
- - Updated dayjs @Eray Hanoğlu
382
- - Updated deps @Eray Hanoğlu
383
- - Updated deps @Eray Hanoğlu
384
- - Fixed isObject coerce issue @Eray Hanoğlu
package/cjs/constants.js DELETED
@@ -1,7 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.VALIDATE_NESTED_METADATA = exports.VALIDATE_METADATA = exports.preValidation = exports.postValidation = void 0;
4
- exports.postValidation = Symbol('postValidation');
5
- exports.preValidation = Symbol('preValidation');
6
- exports.VALIDATE_METADATA = Symbol('VALIDATE_METADATA');
7
- exports.VALIDATE_NESTED_METADATA = Symbol('VALIDATE_NESTED_METADATA');
@@ -1,5 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.kOptions = exports.kValidatorFn = void 0;
4
- exports.kValidatorFn = Symbol.for('kValidatorFn');
5
- exports.kOptions = Symbol.for('kOptions');
@@ -1,74 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.Context = void 0;
4
- const omit_undefined_js_1 = require("../helpers/omit-undefined.js");
5
- const validation_error_js_1 = require("./validation-error.js");
6
- const VARIABLE_REPLACE_PATTERN = /{{([^}]*)}}/g;
7
- const OPTIONAL_VAR_PATTERN = /^([^?]+)(?:\||(.*))?$/;
8
- class Context {
9
- constructor(options) {
10
- this.isRoot = true;
11
- this.errors = [];
12
- Object.assign(this, options);
13
- }
14
- fail(rule, message, value, details) {
15
- const issue = (0, omit_undefined_js_1.omitUndefined)({
16
- message: message instanceof Error ? message.message : String(message),
17
- rule: rule.id,
18
- root: this.root,
19
- location: this.location,
20
- context: this.context,
21
- property: this.property,
22
- index: this.index,
23
- label: this.label,
24
- value,
25
- ...details,
26
- });
27
- issue.value = value;
28
- if (this.onFail) {
29
- const x = this.onFail(issue, this);
30
- if (!x)
31
- return;
32
- if (typeof x === 'object')
33
- Object.assign(issue, x);
34
- else
35
- issue.message = String(x);
36
- }
37
- issue.message = ('' + issue.message).replace(VARIABLE_REPLACE_PATTERN, (x, g) => {
38
- const m = OPTIONAL_VAR_PATTERN.exec(g);
39
- if (!m)
40
- return x;
41
- const k = m[1];
42
- let v = issue[k];
43
- if (k === 'value') {
44
- const s = String(issue.value);
45
- return s.length < 30 ? s : s.substring(0, 30) + '..';
46
- }
47
- if (!v && k === 'label' && (this.location || this.property)) {
48
- v = '`' + (this.location || this.property) + '`';
49
- }
50
- if (v != null)
51
- return v;
52
- if (m[2])
53
- return m[2];
54
- return m[1] === 'label' ? 'Value' : x;
55
- });
56
- this.errors.push(issue);
57
- if (this.errors.length >= (this.maxErrors ?? Infinity)) {
58
- throw new validation_error_js_1.ValidationError(this.errors);
59
- }
60
- }
61
- extend(options) {
62
- const extended = {};
63
- if (options) {
64
- for (const [k, v] of Object.entries(options)) {
65
- if (v !== undefined)
66
- extended[k] = v;
67
- }
68
- }
69
- extended.isRoot = false;
70
- Object.setPrototypeOf(extended, this);
71
- return extended;
72
- }
73
- }
74
- exports.Context = Context;
package/cjs/core/index.js DELETED
@@ -1,9 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const tslib_1 = require("tslib");
4
- tslib_1.__exportStar(require("./constants.js"), exports);
5
- tslib_1.__exportStar(require("./context.js"), exports);
6
- tslib_1.__exportStar(require("./types.js"), exports);
7
- tslib_1.__exportStar(require("./utilities.js"), exports);
8
- tslib_1.__exportStar(require("./validation-error.js"), exports);
9
- tslib_1.__exportStar(require("./validator.js"), exports);
package/cjs/core/types.js DELETED
@@ -1,2 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });