@astral/validations 4.24.2 → 4.24.4

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/array/array.d.ts +1 -1
  2. package/boolean/boolean.d.ts +1 -1
  3. package/containsPunctuationMarks/containsPunctuationMarks.js +1 -1
  4. package/core/compose/compose.d.ts +1 -1
  5. package/core/composeAsync/composeAsync.d.ts +1 -1
  6. package/core/context/createContext/createContext.d.ts +1 -1
  7. package/core/errors/ArrayError/ArrayError.d.ts +1 -1
  8. package/core/errors/ErrorMap/ErrorMap.d.ts +1 -1
  9. package/core/errors/ErrorMap/index.d.ts +1 -1
  10. package/core/errors/ErrorMap/index.js +1 -1
  11. package/core/errors/SimpleError/SimpleError.d.ts +5 -5
  12. package/core/errors/SimpleError/createSimpleError/createSimpleError.d.ts +1 -1
  13. package/core/errors/SimpleError/index.d.ts +1 -1
  14. package/core/errors/SimpleError/index.js +1 -1
  15. package/core/errors/index.d.ts +3 -3
  16. package/core/errors/index.js +3 -3
  17. package/core/errors/types.d.ts +1 -1
  18. package/core/guard/createGuard/createGuard.d.ts +10 -10
  19. package/core/guard/createGuard/createGuard.js +1 -1
  20. package/core/index.d.ts +4 -4
  21. package/core/index.js +4 -4
  22. package/core/logger/logger.js +1 -0
  23. package/core/rule/callAsyncRule/callAsyncRule.d.ts +2 -2
  24. package/core/rule/callRule/callRule.d.ts +2 -2
  25. package/core/rule/createRule/createRule.d.ts +5 -5
  26. package/core/rule/index.d.ts +3 -3
  27. package/core/rule/index.js +3 -3
  28. package/core/rule/required/index.d.ts +1 -1
  29. package/core/rule/required/index.js +1 -1
  30. package/core/rule/required/required.js +3 -1
  31. package/core/types.d.ts +1 -1
  32. package/core/utils/index.d.ts +1 -1
  33. package/core/utils/index.js +1 -1
  34. package/core/utils/isHasConsecutiveChars/isHasConsecutiveChars.js +1 -1
  35. package/core/utils/isStringOfZeros/isStringOfZeros.js +1 -1
  36. package/date/date.d.ts +1 -1
  37. package/deepPartial/deepPartial.d.ts +2 -2
  38. package/email/email.js +3 -1
  39. package/emailOrPhone/constants.js +1 -1
  40. package/emailOrPhone/emailOrPhone.js +4 -5
  41. package/index.d.ts +48 -48
  42. package/index.js +48 -48
  43. package/innFL/index.d.ts +1 -1
  44. package/innFL/index.js +1 -1
  45. package/innIP/index.d.ts +1 -1
  46. package/innIP/index.js +1 -1
  47. package/innTwelveSymbols/index.d.ts +1 -1
  48. package/innTwelveSymbols/index.js +1 -1
  49. package/innUL/index.d.ts +1 -1
  50. package/innUL/index.js +1 -1
  51. package/length/index.d.ts +1 -1
  52. package/length/index.js +1 -1
  53. package/max/index.d.ts +1 -1
  54. package/max/index.js +1 -1
  55. package/max/max.d.ts +6 -6
  56. package/max/max.js +1 -0
  57. package/min/index.d.ts +1 -1
  58. package/min/index.js +1 -1
  59. package/min/min.d.ts +6 -6
  60. package/min/min.js +1 -0
  61. package/minYearsOld/index.d.ts +1 -1
  62. package/minYearsOld/index.js +1 -1
  63. package/minYearsOld/minYearsOld.d.ts +1 -1
  64. package/mobilePhone/index.d.ts +1 -1
  65. package/mobilePhone/index.js +1 -1
  66. package/node/array/array.d.ts +1 -1
  67. package/node/boolean/boolean.d.ts +1 -1
  68. package/node/containsPunctuationMarks/containsPunctuationMarks.js +1 -1
  69. package/node/core/compose/compose.d.ts +1 -1
  70. package/node/core/composeAsync/composeAsync.d.ts +1 -1
  71. package/node/core/context/createContext/createContext.d.ts +1 -1
  72. package/node/core/errors/ArrayError/ArrayError.d.ts +1 -1
  73. package/node/core/errors/ErrorMap/ErrorMap.d.ts +1 -1
  74. package/node/core/errors/ErrorMap/index.d.ts +1 -1
  75. package/node/core/errors/ErrorMap/index.js +1 -1
  76. package/node/core/errors/SimpleError/SimpleError.d.ts +5 -5
  77. package/node/core/errors/SimpleError/createSimpleError/createSimpleError.d.ts +1 -1
  78. package/node/core/errors/SimpleError/index.d.ts +1 -1
  79. package/node/core/errors/SimpleError/index.js +1 -1
  80. package/node/core/errors/index.d.ts +3 -3
  81. package/node/core/errors/index.js +3 -3
  82. package/node/core/errors/types.d.ts +1 -1
  83. package/node/core/guard/createGuard/createGuard.d.ts +10 -10
  84. package/node/core/guard/createGuard/createGuard.js +1 -1
  85. package/node/core/index.d.ts +4 -4
  86. package/node/core/index.js +4 -4
  87. package/node/core/logger/logger.js +1 -0
  88. package/node/core/rule/callAsyncRule/callAsyncRule.d.ts +2 -2
  89. package/node/core/rule/callRule/callRule.d.ts +2 -2
  90. package/node/core/rule/createRule/createRule.d.ts +5 -5
  91. package/node/core/rule/index.d.ts +3 -3
  92. package/node/core/rule/index.js +3 -3
  93. package/node/core/rule/required/index.d.ts +1 -1
  94. package/node/core/rule/required/index.js +1 -1
  95. package/node/core/rule/required/required.js +3 -1
  96. package/node/core/types.d.ts +1 -1
  97. package/node/core/utils/index.d.ts +1 -1
  98. package/node/core/utils/index.js +1 -1
  99. package/node/core/utils/isHasConsecutiveChars/isHasConsecutiveChars.js +1 -1
  100. package/node/core/utils/isStringOfZeros/isStringOfZeros.js +1 -1
  101. package/node/date/date.d.ts +1 -1
  102. package/node/deepPartial/deepPartial.d.ts +2 -2
  103. package/node/email/email.js +3 -1
  104. package/node/emailOrPhone/emailOrPhone.js +4 -5
  105. package/node/index.d.ts +48 -48
  106. package/node/index.js +136 -136
  107. package/node/innFL/index.d.ts +1 -1
  108. package/node/innFL/index.js +1 -1
  109. package/node/innIP/index.d.ts +1 -1
  110. package/node/innIP/index.js +1 -1
  111. package/node/innTwelveSymbols/index.d.ts +1 -1
  112. package/node/innTwelveSymbols/index.js +1 -1
  113. package/node/innUL/index.d.ts +1 -1
  114. package/node/innUL/index.js +1 -1
  115. package/node/length/index.d.ts +1 -1
  116. package/node/length/index.js +1 -1
  117. package/node/max/index.d.ts +1 -1
  118. package/node/max/index.js +1 -1
  119. package/node/max/max.d.ts +6 -6
  120. package/node/max/max.js +1 -0
  121. package/node/min/index.d.ts +1 -1
  122. package/node/min/index.js +1 -1
  123. package/node/min/min.d.ts +6 -6
  124. package/node/min/min.js +1 -0
  125. package/node/minYearsOld/index.d.ts +1 -1
  126. package/node/minYearsOld/index.js +1 -1
  127. package/node/minYearsOld/minYearsOld.d.ts +1 -1
  128. package/node/mobilePhone/index.d.ts +1 -1
  129. package/node/mobilePhone/index.js +1 -1
  130. package/node/number/index.d.ts +1 -1
  131. package/node/number/index.js +1 -1
  132. package/node/number/number.d.ts +1 -1
  133. package/node/object/index.d.ts +1 -1
  134. package/node/object/index.js +1 -1
  135. package/node/object/object.d.ts +6 -6
  136. package/node/object/object.js +6 -4
  137. package/node/object/objectAsync/objectAsync.d.ts +9 -9
  138. package/node/object/objectAsync/objectAsync.js +7 -5
  139. package/node/ogrnIP/index.d.ts +1 -1
  140. package/node/ogrnIP/index.js +1 -1
  141. package/node/ogrnUL/index.d.ts +1 -1
  142. package/node/ogrnUL/index.js +1 -1
  143. package/node/or/or.js +1 -1
  144. package/node/partial/partial.d.ts +1 -1
  145. package/node/passportNumber/passportNumber.js +1 -1
  146. package/node/pattern/index.d.ts +1 -1
  147. package/node/pattern/index.js +1 -1
  148. package/node/rangeDate/rangeDate.d.ts +1 -1
  149. package/node/rangeDate/rangeDate.js +9 -3
  150. package/node/rangeDateMinMax/rangeDateMinMax.js +3 -1
  151. package/node/snils/index.d.ts +1 -1
  152. package/node/snils/index.js +1 -1
  153. package/node/snils/snils.js +3 -1
  154. package/node/string/index.d.ts +1 -1
  155. package/node/string/index.js +1 -1
  156. package/node/string/string.d.ts +1 -1
  157. package/node/string/stringAsync/stringAsync.d.ts +1 -1
  158. package/node/string/stringAsync/stringAsync.js +1 -1
  159. package/node/toPlainError/toPlainError.js +1 -4
  160. package/node/toPlainError/utils/index.d.ts +1 -1
  161. package/node/toPlainError/utils/index.js +1 -1
  162. package/node/uploadedFile/index.d.ts +1 -1
  163. package/node/uploadedFile/index.js +1 -1
  164. package/node/uploadedFile/uploadedFile.d.ts +1 -1
  165. package/node/uploadedFileList/index.d.ts +1 -1
  166. package/node/uploadedFileList/index.js +1 -1
  167. package/node/uploadedFileList/uploadedFileList.d.ts +1 -1
  168. package/node/uploadedFileList/uploadedFileList.js +1 -1
  169. package/number/index.d.ts +1 -1
  170. package/number/index.js +1 -1
  171. package/number/number.d.ts +1 -1
  172. package/object/index.d.ts +1 -1
  173. package/object/index.js +1 -1
  174. package/object/object.d.ts +6 -6
  175. package/object/object.js +6 -4
  176. package/object/objectAsync/objectAsync.d.ts +9 -9
  177. package/object/objectAsync/objectAsync.js +7 -5
  178. package/ogrnIP/index.d.ts +1 -1
  179. package/ogrnIP/index.js +1 -1
  180. package/ogrnUL/index.d.ts +1 -1
  181. package/ogrnUL/index.js +1 -1
  182. package/or/or.js +1 -1
  183. package/package.json +1 -1
  184. package/partial/partial.d.ts +1 -1
  185. package/passportNumber/passportNumber.js +1 -1
  186. package/pattern/index.d.ts +1 -1
  187. package/pattern/index.js +1 -1
  188. package/rangeDate/rangeDate.d.ts +1 -1
  189. package/rangeDate/rangeDate.js +9 -3
  190. package/rangeDateMinMax/rangeDateMinMax.js +3 -1
  191. package/snils/index.d.ts +1 -1
  192. package/snils/index.js +1 -1
  193. package/snils/snils.js +3 -1
  194. package/string/index.d.ts +1 -1
  195. package/string/index.js +1 -1
  196. package/string/string.d.ts +1 -1
  197. package/string/stringAsync/stringAsync.d.ts +1 -1
  198. package/string/stringAsync/stringAsync.js +1 -1
  199. package/toPlainError/toPlainError.js +1 -4
  200. package/toPlainError/utils/index.d.ts +1 -1
  201. package/toPlainError/utils/index.js +1 -1
  202. package/uploadedFile/index.d.ts +1 -1
  203. package/uploadedFile/index.js +1 -1
  204. package/uploadedFile/uploadedFile.d.ts +1 -1
  205. package/uploadedFileList/index.d.ts +1 -1
  206. package/uploadedFileList/index.js +1 -1
  207. package/uploadedFileList/uploadedFileList.d.ts +1 -1
  208. package/uploadedFileList/uploadedFileList.js +1 -1
@@ -4,6 +4,6 @@ import { type object } from '../object';
4
4
  * @param objectGuard
5
5
  * @example partial(object({ name: string() }))
6
6
  */
7
- export declare const partial: (objectGuard: ReturnType<typeof object>) => import("../core").Guard<{}, {
7
+ export declare const partial: (objectGuard: ReturnType<typeof object>) => import("../core").IGuard<{}, {
8
8
  isPartial?: boolean;
9
9
  }>;
@@ -1,5 +1,5 @@
1
- import { onlyNumber } from '../onlyNumber';
2
1
  import { createRule } from '../core';
2
+ import { onlyNumber } from '../onlyNumber';
3
3
  import { PASSPORT_NUMBER_ERROR_INFO, PASSPORT_NUMBER_LENGTH_ERROR_INFO, PASSPORT_NUMBER_ONLY_DIGITS_ERROR_INFO, } from './constants';
4
4
  /**
5
5
  * Проверяет валиден ли номер паспорта
@@ -1,2 +1,2 @@
1
- export * from './pattern';
2
1
  export * from './constants';
2
+ export * from './pattern';
package/pattern/index.js CHANGED
@@ -1,2 +1,2 @@
1
- export * from './pattern';
2
1
  export * from './constants';
2
+ export * from './pattern';
@@ -46,5 +46,5 @@ type RangeDateParams = {
46
46
  * validate({ start: new Date(), end: new Date() });
47
47
  * ```
48
48
  */
49
- export declare const rangeDate: <TLastSchemaValues extends Record<string, unknown>>(...rules: ValidationRule<RangeDateValue, TLastSchemaValues>[]) => import("../core").Guard<TLastSchemaValues, RangeDateParams>;
49
+ export declare const rangeDate: <TLastSchemaValues extends Record<string, unknown>>(...rules: ValidationRule<RangeDateValue, TLastSchemaValues>[]) => import("../core").IGuard<TLastSchemaValues, RangeDateParams>;
50
50
  export {};
@@ -10,12 +10,18 @@ import { RANGE_DATE_END_EARLIER_START_ERROR_INFO, RANGE_DATE_END_INVALID_ERROR_I
10
10
  * validate({ start: new Date(), end: new Date() });
11
11
  * ```
12
12
  */
13
- export const rangeDate = (...rules) => createGuard((externalValue, ctx, params) => {
13
+ export const rangeDate = (...rules) => createGuard(
14
+ // biome-ignore lint/complexity/noExcessiveCognitiveComplexity: <>
15
+ (externalValue, ctx, params) => {
14
16
  const { required, messages } = Object.assign(Object.assign({}, (params || {})), { required: {
15
- start: (params === null || params === void 0 ? void 0 : params.required) && 'start' in (params === null || params === void 0 ? void 0 : params.required)
17
+ start:
18
+ // biome-ignore lint/correctness/noUnsafeOptionalChaining: <>
19
+ (params === null || params === void 0 ? void 0 : params.required) && 'start' in (params === null || params === void 0 ? void 0 : params.required)
16
20
  ? params === null || params === void 0 ? void 0 : params.required.start
17
21
  : true,
18
- end: (params === null || params === void 0 ? void 0 : params.required) && 'end' in (params === null || params === void 0 ? void 0 : params.required)
22
+ end:
23
+ // biome-ignore lint/correctness/noUnsafeOptionalChaining: <>
24
+ (params === null || params === void 0 ? void 0 : params.required) && 'end' in (params === null || params === void 0 ? void 0 : params.required)
19
25
  ? params === null || params === void 0 ? void 0 : params.required.end
20
26
  : true,
21
27
  } });
@@ -13,7 +13,9 @@ const formatDateToView = (date) => {
13
13
  * validate({ start: new Date(), end: new Date() });
14
14
  * ```
15
15
  */
16
- export const rangeDateMinMax = (params) => createRule((value, ctx) => {
16
+ export const rangeDateMinMax = (params) =>
17
+ // biome-ignore lint/complexity/noExcessiveCognitiveComplexity: <>
18
+ createRule((value, ctx) => {
17
19
  var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v;
18
20
  if (!value.start && !value.end) {
19
21
  return undefined;
package/snils/index.d.ts CHANGED
@@ -1,2 +1,2 @@
1
- export * from './snils';
2
1
  export * from './constants';
2
+ export * from './snils';
package/snils/index.js CHANGED
@@ -1,2 +1,2 @@
1
- export * from './snils';
2
1
  export * from './constants';
2
+ export * from './snils';
package/snils/snils.js CHANGED
@@ -18,7 +18,9 @@ const compareCheckSum = (calculatedCheckSum, checkSum) => {
18
18
  * validate('15657325992');
19
19
  * ```
20
20
  */
21
- export const snils = (params) => createRule((value, ctx) => {
21
+ export const snils = (params) => createRule(
22
+ // biome-ignore lint/complexity/noExcessiveCognitiveComplexity: <>
23
+ (value, ctx) => {
22
24
  const createSnilsError = () => ctx.createError({
23
25
  message: (params === null || params === void 0 ? void 0 : params.message) || SNILS_ERROR_INFO.message,
24
26
  code: SNILS_ERROR_INFO.code,
package/string/index.d.ts CHANGED
@@ -1,3 +1,3 @@
1
+ export * from './constants';
1
2
  export * from './string';
2
3
  export * from './stringAsync';
3
- export * from './constants';
package/string/index.js CHANGED
@@ -1,3 +1,3 @@
1
+ export * from './constants';
1
2
  export * from './string';
2
3
  export * from './stringAsync';
3
- export * from './constants';
@@ -1,2 +1,2 @@
1
1
  import { type ValidationRule } from '../core';
2
- export declare const string: <TLastSchemaValues extends Record<string, unknown>>(...rules: ValidationRule<string, TLastSchemaValues>[]) => import("../core").Guard<TLastSchemaValues, {}>;
2
+ export declare const string: <TLastSchemaValues extends Record<string, unknown>>(...rules: ValidationRule<string, TLastSchemaValues>[]) => import("../core").IGuard<TLastSchemaValues, {}>;
@@ -3,4 +3,4 @@ import { type AsyncValidationRule, type ValidationRule } from '../../core';
3
3
  * Позволяет использовать для валидации асинхронные правила
4
4
  * @example stringAsync(async () => undefined)
5
5
  */
6
- export declare const stringAsync: <TLastSchemaValues extends Record<string, unknown>>(...rules: Array<ValidationRule<string, TLastSchemaValues> | AsyncValidationRule<string, TLastSchemaValues>>) => import("../../core").AsyncGuard<TLastSchemaValues, {}>;
6
+ export declare const stringAsync: <TLastSchemaValues extends Record<string, unknown>>(...rules: Array<ValidationRule<string, TLastSchemaValues> | AsyncValidationRule<string, TLastSchemaValues>>) => import("../../core").IAsyncGuard<TLastSchemaValues, {}>;
@@ -8,8 +8,8 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
8
8
  });
9
9
  };
10
10
  import { composeAsync, createGuard, } from '../../core';
11
- import { isString } from '../utils';
12
11
  import { STRING_TYPE_ERROR_INFO } from '../constants';
12
+ import { isString } from '../utils';
13
13
  // TODO: необходимо реализовать переиспользование логики между string и stringAsync
14
14
  /**
15
15
  * Позволяет использовать для валидации асинхронные правила
@@ -1,11 +1,8 @@
1
1
  import { ValidationArrayError, ValidationErrorMap, } from '../core';
2
2
  import { generateArrayPath, generateObjectPath } from './utils';
3
- const toPlainArrayResult = (error, formatErrorInfo, path) => error.cause.errorArray.map((errorItem, index) =>
4
- // eslint-disable-next-line @typescript-eslint/no-use-before-define
5
- toPlainError(errorItem, formatErrorInfo, generateArrayPath(index, path)));
3
+ const toPlainArrayResult = (error, formatErrorInfo, path) => error.cause.errorArray.map((errorItem, index) => toPlainError(errorItem, formatErrorInfo, generateArrayPath(index, path)));
6
4
  function toPlainErrorMap(error, formatErrorInfo, path) {
7
5
  return Object.entries(error.cause.errorMap).reduce((plainErrorMap, [key, currentError]) => {
8
- // eslint-disable-next-line @typescript-eslint/no-use-before-define
9
6
  const plainError = toPlainError(currentError, formatErrorInfo, generateObjectPath(key, path));
10
7
  if (plainError === undefined) {
11
8
  return plainErrorMap;
@@ -1,2 +1,2 @@
1
- export * from './generateObjectPath';
2
1
  export * from './generateArrayPath';
2
+ export * from './generateObjectPath';
@@ -1,2 +1,2 @@
1
- export * from './generateObjectPath';
2
1
  export * from './generateArrayPath';
2
+ export * from './generateObjectPath';
@@ -1,2 +1,2 @@
1
- export * from './uploadedFile';
2
1
  export * from './constants';
2
+ export * from './uploadedFile';
@@ -1,2 +1,2 @@
1
- export * from './uploadedFile';
2
1
  export * from './constants';
2
+ export * from './uploadedFile';
@@ -27,4 +27,4 @@ import type { UploadFile } from './types';
27
27
  * });
28
28
  * ```
29
29
  */
30
- export declare const uploadedFile: <TLastSchemeValues extends Record<string, unknown>>(...rules: ValidationRule<UploadFile, TLastSchemeValues>[]) => import("../core").Guard<TLastSchemeValues, {}>;
30
+ export declare const uploadedFile: <TLastSchemeValues extends Record<string, unknown>>(...rules: ValidationRule<UploadFile, TLastSchemeValues>[]) => import("../core").IGuard<TLastSchemeValues, {}>;
@@ -1,2 +1,2 @@
1
- export * from './uploadedFileList';
2
1
  export * from './constants';
2
+ export * from './uploadedFileList';
@@ -1,2 +1,2 @@
1
- export * from './uploadedFileList';
2
1
  export * from './constants';
2
+ export * from './uploadedFileList';
@@ -21,4 +21,4 @@ import { type UploadFile } from '../uploadedFile/types';
21
21
  * ]);
22
22
  * ```
23
23
  */
24
- export declare const uploadedFileList: <TLastSchemeValues extends Record<string, unknown>>(...rules: ValidationRule<UploadFile[], TLastSchemeValues>[]) => import("../core").Guard<TLastSchemeValues, {}>;
24
+ export declare const uploadedFileList: <TLastSchemeValues extends Record<string, unknown>>(...rules: ValidationRule<UploadFile[], TLastSchemeValues>[]) => import("../core").IGuard<TLastSchemeValues, {}>;
@@ -1,5 +1,5 @@
1
- import { compose, createGuard, } from '../core';
2
1
  import { array } from '../array';
2
+ import { compose, createGuard, } from '../core';
3
3
  import { uploadedFile } from '../uploadedFile';
4
4
  import { FILE_LIST_NOT_ARRAY_ERROR_INFO } from './constants';
5
5
  /**