@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
@@ -1,3 +1,3 @@
1
- export * from './object';
2
1
  export * from './constants';
2
+ export * from './object';
3
3
  export * from './objectAsync';
@@ -14,6 +14,6 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
14
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
- __exportStar(require("./object"), exports);
18
17
  __exportStar(require("./constants"), exports);
18
+ __exportStar(require("./object"), exports);
19
19
  __exportStar(require("./objectAsync"), exports);
@@ -1,11 +1,11 @@
1
- import { type Guard, type ValidationContext, type ValidationRule } from '../core';
1
+ import { type IGuard, type ValidationContext, type ValidationRule } from '../core';
2
2
  /**
3
3
  * Специальный итерфейс Guard для object. В данном интерфейсе ctx required
4
4
  * Переопределение необходимо для того, чтобы ts показывал, что ctx required в кастомных правилах
5
5
  */
6
- interface ObjectPropGuard<TLastSchemaValues extends Record<string, unknown>> {
7
- (value: Parameters<Guard<TLastSchemaValues>>[0], ctx: ValidationContext<TLastSchemaValues>): ReturnType<Guard<TLastSchemaValues>>;
8
- define: Guard<TLastSchemaValues>['define'];
6
+ interface IObjectPropGuard<TLastSchemaValues extends Record<string, unknown>> {
7
+ (value: Parameters<IGuard<TLastSchemaValues>>[0], ctx: ValidationContext<TLastSchemaValues>): ReturnType<IGuard<TLastSchemaValues>>;
8
+ define: IGuard<TLastSchemaValues>['define'];
9
9
  }
10
10
  type AdditionalDefOptions = {
11
11
  /**
@@ -16,7 +16,7 @@ type AdditionalDefOptions = {
16
16
  /**
17
17
  * Возможные значения, принимаемые схемой
18
18
  */
19
- export type SchemaValue<TValue extends Record<string, unknown>> = ObjectPropGuard<TValue> | ValidationRule<unknown, TValue>;
19
+ export type SchemaValue<TValue extends Record<string, unknown>> = IObjectPropGuard<TValue> | ValidationRule<unknown, TValue>;
20
20
  /**
21
21
  * Схема правил валдиации для объекта
22
22
  */
@@ -44,6 +44,6 @@ export type Schema<TValue extends Record<string, unknown>> = Record<keyof TValue
44
44
  * });
45
45
  * ```
46
46
  */
47
- export declare const object: <TValue extends Record<string, unknown>, TLastSchemaValues extends Record<string, unknown> = {}>(schema: Schema<TValue>) => Guard<TLastSchemaValues, AdditionalDefOptions>;
47
+ export declare const object: <TValue extends Record<string, unknown>, TLastSchemaValues extends Record<string, unknown> = {}>(schema: Schema<TValue>) => IGuard<TLastSchemaValues, AdditionalDefOptions>;
48
48
  export type ObjectGuard<TValue extends Record<string, unknown>> = ReturnType<typeof object<TValue>>;
49
49
  export {};
@@ -4,8 +4,8 @@ exports.object = void 0;
4
4
  const utils_1 = require("@astral/utils");
5
5
  const core_1 = require("../core");
6
6
  const optional_1 = require("../optional");
7
- const isEmptyErrors_1 = require("./isEmptyErrors");
8
7
  const constants_1 = require("./constants");
8
+ const isEmptyErrors_1 = require("./isEmptyErrors");
9
9
  /**
10
10
  * Guard для объекта
11
11
  * @param schema - схема валидации объекта
@@ -39,10 +39,12 @@ const object = (schema) => (0, core_1.createGuard)((value, ctx, { typeErrorMessa
39
39
  const generateErrorMap = () => {
40
40
  const schemaEntries = Object.entries(schema);
41
41
  const isOptional = context.global.overrides.objectIsPartial || isPartial;
42
- return schemaEntries.reduce((errorMap, [key, rule]) => {
42
+ return schemaEntries.reduce((errorMapResult, [key, rule]) => {
43
43
  const callRule = isOptional ? (0, optional_1.optional)(rule) : rule;
44
- errorMap[key] = (0, core_1.callRule)(callRule, value[key], context);
45
- return errorMap;
44
+ errorMapResult[key] = (0, core_1.callRule)(callRule,
45
+ // biome-ignore lint/nursery/noShadow: <>
46
+ value[key], context);
47
+ return errorMapResult;
46
48
  }, {});
47
49
  };
48
50
  const errorMap = generateErrorMap();
@@ -1,15 +1,15 @@
1
- import { type AsyncGuard, type AsyncValidationRule, type Guard, type ValidationContext, type ValidationRule } from '../../core';
1
+ import { type AsyncValidationRule, type IAsyncGuard, type IGuard, type ValidationContext, type ValidationRule } from '../../core';
2
2
  /**
3
3
  * Специальный итерфейс Guard для object. В данном интерфейсе ctx required
4
4
  * Переопределение необходимо для того, чтобы ts показывал, что ctx required в кастомных правилах
5
5
  */
6
- interface ObjectPropGuard<TLastSchemaValues extends Record<string, unknown>> {
7
- (value: Parameters<Guard<TLastSchemaValues>>[0], ctx: ValidationContext<TLastSchemaValues>): ReturnType<Guard<TLastSchemaValues>>;
8
- define: Guard<TLastSchemaValues>['define'];
6
+ interface IObjectPropGuard<TLastSchemaValues extends Record<string, unknown>> {
7
+ (value: Parameters<IGuard<TLastSchemaValues>>[0], ctx: ValidationContext<TLastSchemaValues>): ReturnType<IGuard<TLastSchemaValues>>;
8
+ define: IGuard<TLastSchemaValues>['define'];
9
9
  }
10
- interface AsyncObjectPropGuard<TLastSchemaValues extends Record<string, unknown>> {
11
- (value: Parameters<Guard<TLastSchemaValues>>[0], ctx: ValidationContext<TLastSchemaValues>): ReturnType<AsyncGuard<TLastSchemaValues>>;
12
- define: AsyncGuard<TLastSchemaValues>['define'];
10
+ interface IAsyncObjectPropGuard<TLastSchemaValues extends Record<string, unknown>> {
11
+ (value: Parameters<IGuard<TLastSchemaValues>>[0], ctx: ValidationContext<TLastSchemaValues>): ReturnType<IAsyncGuard<TLastSchemaValues>>;
12
+ define: IAsyncGuard<TLastSchemaValues>['define'];
13
13
  }
14
14
  type AdditionalDefOptions = {
15
15
  /**
@@ -20,7 +20,7 @@ type AdditionalDefOptions = {
20
20
  /**
21
21
  * Возможные значения, принимаемые схемой
22
22
  */
23
- export type AsyncSchemaValue<TValue extends Record<string, unknown>> = ObjectPropGuard<TValue> | AsyncObjectPropGuard<TValue> | ValidationRule<unknown, TValue> | AsyncValidationRule<unknown, TValue>;
23
+ export type AsyncSchemaValue<TValue extends Record<string, unknown>> = IObjectPropGuard<TValue> | IAsyncObjectPropGuard<TValue> | ValidationRule<unknown, TValue> | AsyncValidationRule<unknown, TValue>;
24
24
  /**
25
25
  * Схема правил валдиации для объекта
26
26
  */
@@ -56,6 +56,6 @@ export type AsyncSchema<TValue extends Record<string, unknown>> = Record<keyof T
56
56
  * });
57
57
  * ```
58
58
  */
59
- export declare const objectAsync: <TValue extends Record<string, unknown>, TLastSchemaValues extends Record<string, unknown> = {}>(schema: AsyncSchema<TValue>) => AsyncGuard<TLastSchemaValues, AdditionalDefOptions>;
59
+ export declare const objectAsync: <TValue extends Record<string, unknown>, TLastSchemaValues extends Record<string, unknown> = {}>(schema: AsyncSchema<TValue>) => IAsyncGuard<TLastSchemaValues, AdditionalDefOptions>;
60
60
  export type ObjectAsyncGuard<TValue extends Record<string, unknown>> = ReturnType<typeof objectAsync<TValue>>;
61
61
  export {};
@@ -13,8 +13,8 @@ exports.objectAsync = void 0;
13
13
  const utils_1 = require("@astral/utils");
14
14
  const core_1 = require("../../core");
15
15
  const optional_1 = require("../../optional");
16
- const isEmptyErrors_1 = require("../isEmptyErrors");
17
16
  const constants_1 = require("../constants");
17
+ const isEmptyErrors_1 = require("../isEmptyErrors");
18
18
  // TODO: необходимо реализовать переиспользование логики между object и objectAsync
19
19
  /**
20
20
  * Guard для объекта, который поддерживает асинхронную валидацию
@@ -59,12 +59,14 @@ const objectAsync = (schema) => (0, core_1.createGuard)((value_1, ctx_1, _a) =>
59
59
  const isOptional = context.global.overrides.objectIsPartial || isPartial;
60
60
  const results = yield Promise.all(schemaEntries.map(([key, rule]) => {
61
61
  const callRule = isOptional ? (0, optional_1.optionalAsync)(rule) : rule;
62
- return (0, core_1.callAsyncRule)(callRule, value[key], context);
62
+ return (0, core_1.callAsyncRule)(callRule,
63
+ // biome-ignore lint/nursery/noShadow: <>
64
+ value[key], context);
63
65
  }));
64
- return results.reduce((errorMap, validationResult, index) => {
66
+ return results.reduce((errorMapResult, validationResult, index) => {
65
67
  const [key] = schemaEntries[index];
66
- errorMap[key] = validationResult;
67
- return errorMap;
68
+ errorMapResult[key] = validationResult;
69
+ return errorMapResult;
68
70
  }, {});
69
71
  });
70
72
  const errorMap = yield generateErrorMap();
@@ -1,2 +1,2 @@
1
- export * from './ogrnIP';
2
1
  export * from './constants';
2
+ export * from './ogrnIP';
@@ -14,5 +14,5 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
14
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
- __exportStar(require("./ogrnIP"), exports);
18
17
  __exportStar(require("./constants"), exports);
18
+ __exportStar(require("./ogrnIP"), exports);
@@ -1,2 +1,2 @@
1
- export * from './ogrnUL';
2
1
  export * from './constants';
2
+ export * from './ogrnUL';
@@ -14,5 +14,5 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
14
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
- __exportStar(require("./ogrnUL"), exports);
18
17
  __exportStar(require("./constants"), exports);
18
+ __exportStar(require("./ogrnUL"), exports);
package/node/or/or.js CHANGED
@@ -21,7 +21,7 @@ const or = (...rules) => (0, core_1.createRule)((value, ctx) => {
21
21
  let result;
22
22
  rules.some((rule) => {
23
23
  result = (0, core_1.callRule)(rule, value, ctx);
24
- return result ? false : true;
24
+ return !result;
25
25
  });
26
26
  return result;
27
27
  });
@@ -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,8 +1,8 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.passportNumber = void 0;
4
- const onlyNumber_1 = require("../onlyNumber");
5
4
  const core_1 = require("../core");
5
+ const onlyNumber_1 = require("../onlyNumber");
6
6
  const constants_1 = require("./constants");
7
7
  /**
8
8
  * Проверяет валиден ли номер паспорта
@@ -1,2 +1,2 @@
1
- export * from './pattern';
2
1
  export * from './constants';
2
+ export * from './pattern';
@@ -14,5 +14,5 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
14
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
- __exportStar(require("./pattern"), exports);
18
17
  __exportStar(require("./constants"), exports);
18
+ __exportStar(require("./pattern"), exports);
@@ -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 {};
@@ -13,12 +13,18 @@ const constants_1 = require("./constants");
13
13
  * validate({ start: new Date(), end: new Date() });
14
14
  * ```
15
15
  */
16
- const rangeDate = (...rules) => (0, core_1.createGuard)((externalValue, ctx, params) => {
16
+ const rangeDate = (...rules) => (0, core_1.createGuard)(
17
+ // biome-ignore lint/complexity/noExcessiveCognitiveComplexity: <>
18
+ (externalValue, ctx, params) => {
17
19
  const { required, messages } = Object.assign(Object.assign({}, (params || {})), { required: {
18
- start: (params === null || params === void 0 ? void 0 : params.required) && 'start' in (params === null || params === void 0 ? void 0 : params.required)
20
+ start:
21
+ // biome-ignore lint/correctness/noUnsafeOptionalChaining: <>
22
+ (params === null || params === void 0 ? void 0 : params.required) && 'start' in (params === null || params === void 0 ? void 0 : params.required)
19
23
  ? params === null || params === void 0 ? void 0 : params.required.start
20
24
  : true,
21
- end: (params === null || params === void 0 ? void 0 : params.required) && 'end' in (params === null || params === void 0 ? void 0 : params.required)
25
+ end:
26
+ // biome-ignore lint/correctness/noUnsafeOptionalChaining: <>
27
+ (params === null || params === void 0 ? void 0 : params.required) && 'end' in (params === null || params === void 0 ? void 0 : params.required)
22
28
  ? params === null || params === void 0 ? void 0 : params.required.end
23
29
  : true,
24
30
  } });
@@ -16,7 +16,9 @@ const formatDateToView = (date) => {
16
16
  * validate({ start: new Date(), end: new Date() });
17
17
  * ```
18
18
  */
19
- const rangeDateMinMax = (params) => (0, core_1.createRule)((value, ctx) => {
19
+ const rangeDateMinMax = (params) =>
20
+ // biome-ignore lint/complexity/noExcessiveCognitiveComplexity: <>
21
+ (0, core_1.createRule)((value, ctx) => {
20
22
  var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v;
21
23
  if (!value.start && !value.end) {
22
24
  return undefined;
@@ -1,2 +1,2 @@
1
- export * from './snils';
2
1
  export * from './constants';
2
+ export * from './snils';
@@ -14,5 +14,5 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
14
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
- __exportStar(require("./snils"), exports);
18
17
  __exportStar(require("./constants"), exports);
18
+ __exportStar(require("./snils"), exports);
@@ -21,7 +21,9 @@ const compareCheckSum = (calculatedCheckSum, checkSum) => {
21
21
  * validate('15657325992');
22
22
  * ```
23
23
  */
24
- const snils = (params) => (0, core_1.createRule)((value, ctx) => {
24
+ const snils = (params) => (0, core_1.createRule)(
25
+ // biome-ignore lint/complexity/noExcessiveCognitiveComplexity: <>
26
+ (value, ctx) => {
25
27
  const createSnilsError = () => ctx.createError({
26
28
  message: (params === null || params === void 0 ? void 0 : params.message) || constants_1.SNILS_ERROR_INFO.message,
27
29
  code: constants_1.SNILS_ERROR_INFO.code,
@@ -1,3 +1,3 @@
1
+ export * from './constants';
1
2
  export * from './string';
2
3
  export * from './stringAsync';
3
- export * from './constants';
@@ -14,6 +14,6 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
14
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./constants"), exports);
17
18
  __exportStar(require("./string"), exports);
18
19
  __exportStar(require("./stringAsync"), exports);
19
- __exportStar(require("./constants"), exports);
@@ -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, {}>;
@@ -11,8 +11,8 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
12
  exports.stringAsync = void 0;
13
13
  const core_1 = require("../../core");
14
- const utils_1 = require("../utils");
15
14
  const constants_1 = require("../constants");
15
+ const utils_1 = require("../utils");
16
16
  // TODO: необходимо реализовать переиспользование логики между string и stringAsync
17
17
  /**
18
18
  * Позволяет использовать для валидации асинхронные правила
@@ -3,12 +3,9 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.toPlainError = void 0;
4
4
  const core_1 = require("../core");
5
5
  const utils_1 = require("./utils");
6
- const toPlainArrayResult = (error, formatErrorInfo, path) => error.cause.errorArray.map((errorItem, index) =>
7
- // eslint-disable-next-line @typescript-eslint/no-use-before-define
8
- (0, exports.toPlainError)(errorItem, formatErrorInfo, (0, utils_1.generateArrayPath)(index, path)));
6
+ const toPlainArrayResult = (error, formatErrorInfo, path) => error.cause.errorArray.map((errorItem, index) => (0, exports.toPlainError)(errorItem, formatErrorInfo, (0, utils_1.generateArrayPath)(index, path)));
9
7
  function toPlainErrorMap(error, formatErrorInfo, path) {
10
8
  return Object.entries(error.cause.errorMap).reduce((plainErrorMap, [key, currentError]) => {
11
- // eslint-disable-next-line @typescript-eslint/no-use-before-define
12
9
  const plainError = (0, exports.toPlainError)(currentError, formatErrorInfo, (0, utils_1.generateObjectPath)(key, path));
13
10
  if (plainError === undefined) {
14
11
  return plainErrorMap;
@@ -1,2 +1,2 @@
1
- export * from './generateObjectPath';
2
1
  export * from './generateArrayPath';
2
+ export * from './generateObjectPath';
@@ -14,5 +14,5 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
14
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
- __exportStar(require("./generateObjectPath"), exports);
18
17
  __exportStar(require("./generateArrayPath"), exports);
18
+ __exportStar(require("./generateObjectPath"), exports);
@@ -1,2 +1,2 @@
1
- export * from './uploadedFile';
2
1
  export * from './constants';
2
+ export * from './uploadedFile';
@@ -14,5 +14,5 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
14
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
- __exportStar(require("./uploadedFile"), exports);
18
17
  __exportStar(require("./constants"), exports);
18
+ __exportStar(require("./uploadedFile"), exports);
@@ -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';
@@ -14,5 +14,5 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
14
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
- __exportStar(require("./uploadedFileList"), exports);
18
17
  __exportStar(require("./constants"), exports);
18
+ __exportStar(require("./uploadedFileList"), exports);
@@ -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,8 +1,8 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.uploadedFileList = void 0;
4
- const core_1 = require("../core");
5
4
  const array_1 = require("../array");
5
+ const core_1 = require("../core");
6
6
  const uploadedFile_1 = require("../uploadedFile");
7
7
  const constants_1 = require("./constants");
8
8
  /**
package/number/index.d.ts CHANGED
@@ -1,2 +1,2 @@
1
- export * from './number';
2
1
  export * from './constants';
2
+ export * from './number';
package/number/index.js CHANGED
@@ -1,2 +1,2 @@
1
- export * from './number';
2
1
  export * from './constants';
2
+ export * from './number';
@@ -15,5 +15,5 @@ type AdditionalDefOptions = {
15
15
  * validate(24);
16
16
  * ```
17
17
  */
18
- export declare const number: <TLastSchemaValues extends Record<string, unknown>>(...rules: ValidationRule<number, TLastSchemaValues>[]) => import("../core").Guard<TLastSchemaValues, AdditionalDefOptions>;
18
+ export declare const number: <TLastSchemaValues extends Record<string, unknown>>(...rules: ValidationRule<number, TLastSchemaValues>[]) => import("../core").IGuard<TLastSchemaValues, AdditionalDefOptions>;
19
19
  export {};
package/object/index.d.ts CHANGED
@@ -1,3 +1,3 @@
1
- export * from './object';
2
1
  export * from './constants';
2
+ export * from './object';
3
3
  export * from './objectAsync';
package/object/index.js CHANGED
@@ -1,3 +1,3 @@
1
- export * from './object';
2
1
  export * from './constants';
2
+ export * from './object';
3
3
  export * from './objectAsync';
@@ -1,11 +1,11 @@
1
- import { type Guard, type ValidationContext, type ValidationRule } from '../core';
1
+ import { type IGuard, type ValidationContext, type ValidationRule } from '../core';
2
2
  /**
3
3
  * Специальный итерфейс Guard для object. В данном интерфейсе ctx required
4
4
  * Переопределение необходимо для того, чтобы ts показывал, что ctx required в кастомных правилах
5
5
  */
6
- interface ObjectPropGuard<TLastSchemaValues extends Record<string, unknown>> {
7
- (value: Parameters<Guard<TLastSchemaValues>>[0], ctx: ValidationContext<TLastSchemaValues>): ReturnType<Guard<TLastSchemaValues>>;
8
- define: Guard<TLastSchemaValues>['define'];
6
+ interface IObjectPropGuard<TLastSchemaValues extends Record<string, unknown>> {
7
+ (value: Parameters<IGuard<TLastSchemaValues>>[0], ctx: ValidationContext<TLastSchemaValues>): ReturnType<IGuard<TLastSchemaValues>>;
8
+ define: IGuard<TLastSchemaValues>['define'];
9
9
  }
10
10
  type AdditionalDefOptions = {
11
11
  /**
@@ -16,7 +16,7 @@ type AdditionalDefOptions = {
16
16
  /**
17
17
  * Возможные значения, принимаемые схемой
18
18
  */
19
- export type SchemaValue<TValue extends Record<string, unknown>> = ObjectPropGuard<TValue> | ValidationRule<unknown, TValue>;
19
+ export type SchemaValue<TValue extends Record<string, unknown>> = IObjectPropGuard<TValue> | ValidationRule<unknown, TValue>;
20
20
  /**
21
21
  * Схема правил валдиации для объекта
22
22
  */
@@ -44,6 +44,6 @@ export type Schema<TValue extends Record<string, unknown>> = Record<keyof TValue
44
44
  * });
45
45
  * ```
46
46
  */
47
- export declare const object: <TValue extends Record<string, unknown>, TLastSchemaValues extends Record<string, unknown> = {}>(schema: Schema<TValue>) => Guard<TLastSchemaValues, AdditionalDefOptions>;
47
+ export declare const object: <TValue extends Record<string, unknown>, TLastSchemaValues extends Record<string, unknown> = {}>(schema: Schema<TValue>) => IGuard<TLastSchemaValues, AdditionalDefOptions>;
48
48
  export type ObjectGuard<TValue extends Record<string, unknown>> = ReturnType<typeof object<TValue>>;
49
49
  export {};
package/object/object.js CHANGED
@@ -1,8 +1,8 @@
1
1
  import { isPlainObject } from '@astral/utils';
2
2
  import { callRule as callRecursiveRule, createContext, createErrorMap, createGuard, } from '../core';
3
3
  import { optional } from '../optional';
4
- import { isEmptyErrors } from './isEmptyErrors';
5
4
  import { OBJECT_TYPE_ERROR_INFO } from './constants';
5
+ import { isEmptyErrors } from './isEmptyErrors';
6
6
  /**
7
7
  * Guard для объекта
8
8
  * @param schema - схема валидации объекта
@@ -36,10 +36,12 @@ export const object = (schema) => createGuard((value, ctx, { typeErrorMessage, i
36
36
  const generateErrorMap = () => {
37
37
  const schemaEntries = Object.entries(schema);
38
38
  const isOptional = context.global.overrides.objectIsPartial || isPartial;
39
- return schemaEntries.reduce((errorMap, [key, rule]) => {
39
+ return schemaEntries.reduce((errorMapResult, [key, rule]) => {
40
40
  const callRule = isOptional ? optional(rule) : rule;
41
- errorMap[key] = callRecursiveRule(callRule, value[key], context);
42
- return errorMap;
41
+ errorMapResult[key] = callRecursiveRule(callRule,
42
+ // biome-ignore lint/nursery/noShadow: <>
43
+ value[key], context);
44
+ return errorMapResult;
43
45
  }, {});
44
46
  };
45
47
  const errorMap = generateErrorMap();
@@ -1,15 +1,15 @@
1
- import { type AsyncGuard, type AsyncValidationRule, type Guard, type ValidationContext, type ValidationRule } from '../../core';
1
+ import { type AsyncValidationRule, type IAsyncGuard, type IGuard, type ValidationContext, type ValidationRule } from '../../core';
2
2
  /**
3
3
  * Специальный итерфейс Guard для object. В данном интерфейсе ctx required
4
4
  * Переопределение необходимо для того, чтобы ts показывал, что ctx required в кастомных правилах
5
5
  */
6
- interface ObjectPropGuard<TLastSchemaValues extends Record<string, unknown>> {
7
- (value: Parameters<Guard<TLastSchemaValues>>[0], ctx: ValidationContext<TLastSchemaValues>): ReturnType<Guard<TLastSchemaValues>>;
8
- define: Guard<TLastSchemaValues>['define'];
6
+ interface IObjectPropGuard<TLastSchemaValues extends Record<string, unknown>> {
7
+ (value: Parameters<IGuard<TLastSchemaValues>>[0], ctx: ValidationContext<TLastSchemaValues>): ReturnType<IGuard<TLastSchemaValues>>;
8
+ define: IGuard<TLastSchemaValues>['define'];
9
9
  }
10
- interface AsyncObjectPropGuard<TLastSchemaValues extends Record<string, unknown>> {
11
- (value: Parameters<Guard<TLastSchemaValues>>[0], ctx: ValidationContext<TLastSchemaValues>): ReturnType<AsyncGuard<TLastSchemaValues>>;
12
- define: AsyncGuard<TLastSchemaValues>['define'];
10
+ interface IAsyncObjectPropGuard<TLastSchemaValues extends Record<string, unknown>> {
11
+ (value: Parameters<IGuard<TLastSchemaValues>>[0], ctx: ValidationContext<TLastSchemaValues>): ReturnType<IAsyncGuard<TLastSchemaValues>>;
12
+ define: IAsyncGuard<TLastSchemaValues>['define'];
13
13
  }
14
14
  type AdditionalDefOptions = {
15
15
  /**
@@ -20,7 +20,7 @@ type AdditionalDefOptions = {
20
20
  /**
21
21
  * Возможные значения, принимаемые схемой
22
22
  */
23
- export type AsyncSchemaValue<TValue extends Record<string, unknown>> = ObjectPropGuard<TValue> | AsyncObjectPropGuard<TValue> | ValidationRule<unknown, TValue> | AsyncValidationRule<unknown, TValue>;
23
+ export type AsyncSchemaValue<TValue extends Record<string, unknown>> = IObjectPropGuard<TValue> | IAsyncObjectPropGuard<TValue> | ValidationRule<unknown, TValue> | AsyncValidationRule<unknown, TValue>;
24
24
  /**
25
25
  * Схема правил валдиации для объекта
26
26
  */
@@ -56,6 +56,6 @@ export type AsyncSchema<TValue extends Record<string, unknown>> = Record<keyof T
56
56
  * });
57
57
  * ```
58
58
  */
59
- export declare const objectAsync: <TValue extends Record<string, unknown>, TLastSchemaValues extends Record<string, unknown> = {}>(schema: AsyncSchema<TValue>) => AsyncGuard<TLastSchemaValues, AdditionalDefOptions>;
59
+ export declare const objectAsync: <TValue extends Record<string, unknown>, TLastSchemaValues extends Record<string, unknown> = {}>(schema: AsyncSchema<TValue>) => IAsyncGuard<TLastSchemaValues, AdditionalDefOptions>;
60
60
  export type ObjectAsyncGuard<TValue extends Record<string, unknown>> = ReturnType<typeof objectAsync<TValue>>;
61
61
  export {};
@@ -10,8 +10,8 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
10
10
  import { isPlainObject } from '@astral/utils';
11
11
  import { callAsyncRule as callAsyncRecursiveRule, createContext, createErrorMap, createGuard, } from '../../core';
12
12
  import { optionalAsync } from '../../optional';
13
- import { isEmptyErrors } from '../isEmptyErrors';
14
13
  import { OBJECT_TYPE_ERROR_INFO } from '../constants';
14
+ import { isEmptyErrors } from '../isEmptyErrors';
15
15
  // TODO: необходимо реализовать переиспользование логики между object и objectAsync
16
16
  /**
17
17
  * Guard для объекта, который поддерживает асинхронную валидацию
@@ -56,12 +56,14 @@ export const objectAsync = (schema) => createGuard((value_1, ctx_1, _a) => __awa
56
56
  const isOptional = context.global.overrides.objectIsPartial || isPartial;
57
57
  const results = yield Promise.all(schemaEntries.map(([key, rule]) => {
58
58
  const callRule = isOptional ? optionalAsync(rule) : rule;
59
- return callAsyncRecursiveRule(callRule, value[key], context);
59
+ return callAsyncRecursiveRule(callRule,
60
+ // biome-ignore lint/nursery/noShadow: <>
61
+ value[key], context);
60
62
  }));
61
- return results.reduce((errorMap, validationResult, index) => {
63
+ return results.reduce((errorMapResult, validationResult, index) => {
62
64
  const [key] = schemaEntries[index];
63
- errorMap[key] = validationResult;
64
- return errorMap;
65
+ errorMapResult[key] = validationResult;
66
+ return errorMapResult;
65
67
  }, {});
66
68
  });
67
69
  const errorMap = yield generateErrorMap();
package/ogrnIP/index.d.ts CHANGED
@@ -1,2 +1,2 @@
1
- export * from './ogrnIP';
2
1
  export * from './constants';
2
+ export * from './ogrnIP';
package/ogrnIP/index.js CHANGED
@@ -1,2 +1,2 @@
1
- export * from './ogrnIP';
2
1
  export * from './constants';
2
+ export * from './ogrnIP';
package/ogrnUL/index.d.ts CHANGED
@@ -1,2 +1,2 @@
1
- export * from './ogrnUL';
2
1
  export * from './constants';
2
+ export * from './ogrnUL';
package/ogrnUL/index.js CHANGED
@@ -1,2 +1,2 @@
1
- export * from './ogrnUL';
2
1
  export * from './constants';
2
+ export * from './ogrnUL';
package/or/or.js CHANGED
@@ -18,7 +18,7 @@ export const or = (...rules) => createRule((value, ctx) => {
18
18
  let result;
19
19
  rules.some((rule) => {
20
20
  result = callRule(rule, value, ctx);
21
- return result ? false : true;
21
+ return !result;
22
22
  });
23
23
  return result;
24
24
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@astral/validations",
3
- "version": "4.24.2",
3
+ "version": "4.24.4",
4
4
  "main": "./node/index.js",
5
5
  "dependencies": {
6
6
  "@astral/utils": "^1.11.0",