@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.
- package/array/array.d.ts +1 -1
- package/boolean/boolean.d.ts +1 -1
- package/containsPunctuationMarks/containsPunctuationMarks.js +1 -1
- package/core/compose/compose.d.ts +1 -1
- package/core/composeAsync/composeAsync.d.ts +1 -1
- package/core/context/createContext/createContext.d.ts +1 -1
- package/core/errors/ArrayError/ArrayError.d.ts +1 -1
- package/core/errors/ErrorMap/ErrorMap.d.ts +1 -1
- package/core/errors/ErrorMap/index.d.ts +1 -1
- package/core/errors/ErrorMap/index.js +1 -1
- package/core/errors/SimpleError/SimpleError.d.ts +5 -5
- package/core/errors/SimpleError/createSimpleError/createSimpleError.d.ts +1 -1
- package/core/errors/SimpleError/index.d.ts +1 -1
- package/core/errors/SimpleError/index.js +1 -1
- package/core/errors/index.d.ts +3 -3
- package/core/errors/index.js +3 -3
- package/core/errors/types.d.ts +1 -1
- package/core/guard/createGuard/createGuard.d.ts +10 -10
- package/core/guard/createGuard/createGuard.js +1 -1
- package/core/index.d.ts +4 -4
- package/core/index.js +4 -4
- package/core/logger/logger.js +1 -0
- package/core/rule/callAsyncRule/callAsyncRule.d.ts +2 -2
- package/core/rule/callRule/callRule.d.ts +2 -2
- package/core/rule/createRule/createRule.d.ts +5 -5
- package/core/rule/index.d.ts +3 -3
- package/core/rule/index.js +3 -3
- package/core/rule/required/index.d.ts +1 -1
- package/core/rule/required/index.js +1 -1
- package/core/rule/required/required.js +3 -1
- package/core/types.d.ts +1 -1
- package/core/utils/index.d.ts +1 -1
- package/core/utils/index.js +1 -1
- package/core/utils/isHasConsecutiveChars/isHasConsecutiveChars.js +1 -1
- package/core/utils/isStringOfZeros/isStringOfZeros.js +1 -1
- package/date/date.d.ts +1 -1
- package/deepPartial/deepPartial.d.ts +2 -2
- package/email/email.js +3 -1
- package/emailOrPhone/constants.js +1 -1
- package/emailOrPhone/emailOrPhone.js +4 -5
- package/index.d.ts +48 -48
- package/index.js +48 -48
- package/innFL/index.d.ts +1 -1
- package/innFL/index.js +1 -1
- package/innIP/index.d.ts +1 -1
- package/innIP/index.js +1 -1
- package/innTwelveSymbols/index.d.ts +1 -1
- package/innTwelveSymbols/index.js +1 -1
- package/innUL/index.d.ts +1 -1
- package/innUL/index.js +1 -1
- package/length/index.d.ts +1 -1
- package/length/index.js +1 -1
- package/max/index.d.ts +1 -1
- package/max/index.js +1 -1
- package/max/max.d.ts +6 -6
- package/max/max.js +1 -0
- package/min/index.d.ts +1 -1
- package/min/index.js +1 -1
- package/min/min.d.ts +6 -6
- package/min/min.js +1 -0
- package/minYearsOld/index.d.ts +1 -1
- package/minYearsOld/index.js +1 -1
- package/minYearsOld/minYearsOld.d.ts +1 -1
- package/mobilePhone/index.d.ts +1 -1
- package/mobilePhone/index.js +1 -1
- package/node/array/array.d.ts +1 -1
- package/node/boolean/boolean.d.ts +1 -1
- package/node/containsPunctuationMarks/containsPunctuationMarks.js +1 -1
- package/node/core/compose/compose.d.ts +1 -1
- package/node/core/composeAsync/composeAsync.d.ts +1 -1
- package/node/core/context/createContext/createContext.d.ts +1 -1
- package/node/core/errors/ArrayError/ArrayError.d.ts +1 -1
- package/node/core/errors/ErrorMap/ErrorMap.d.ts +1 -1
- package/node/core/errors/ErrorMap/index.d.ts +1 -1
- package/node/core/errors/ErrorMap/index.js +1 -1
- package/node/core/errors/SimpleError/SimpleError.d.ts +5 -5
- package/node/core/errors/SimpleError/createSimpleError/createSimpleError.d.ts +1 -1
- package/node/core/errors/SimpleError/index.d.ts +1 -1
- package/node/core/errors/SimpleError/index.js +1 -1
- package/node/core/errors/index.d.ts +3 -3
- package/node/core/errors/index.js +3 -3
- package/node/core/errors/types.d.ts +1 -1
- package/node/core/guard/createGuard/createGuard.d.ts +10 -10
- package/node/core/guard/createGuard/createGuard.js +1 -1
- package/node/core/index.d.ts +4 -4
- package/node/core/index.js +4 -4
- package/node/core/logger/logger.js +1 -0
- package/node/core/rule/callAsyncRule/callAsyncRule.d.ts +2 -2
- package/node/core/rule/callRule/callRule.d.ts +2 -2
- package/node/core/rule/createRule/createRule.d.ts +5 -5
- package/node/core/rule/index.d.ts +3 -3
- package/node/core/rule/index.js +3 -3
- package/node/core/rule/required/index.d.ts +1 -1
- package/node/core/rule/required/index.js +1 -1
- package/node/core/rule/required/required.js +3 -1
- package/node/core/types.d.ts +1 -1
- package/node/core/utils/index.d.ts +1 -1
- package/node/core/utils/index.js +1 -1
- package/node/core/utils/isHasConsecutiveChars/isHasConsecutiveChars.js +1 -1
- package/node/core/utils/isStringOfZeros/isStringOfZeros.js +1 -1
- package/node/date/date.d.ts +1 -1
- package/node/deepPartial/deepPartial.d.ts +2 -2
- package/node/email/email.js +3 -1
- package/node/emailOrPhone/emailOrPhone.js +4 -5
- package/node/index.d.ts +48 -48
- package/node/index.js +136 -136
- package/node/innFL/index.d.ts +1 -1
- package/node/innFL/index.js +1 -1
- package/node/innIP/index.d.ts +1 -1
- package/node/innIP/index.js +1 -1
- package/node/innTwelveSymbols/index.d.ts +1 -1
- package/node/innTwelveSymbols/index.js +1 -1
- package/node/innUL/index.d.ts +1 -1
- package/node/innUL/index.js +1 -1
- package/node/length/index.d.ts +1 -1
- package/node/length/index.js +1 -1
- package/node/max/index.d.ts +1 -1
- package/node/max/index.js +1 -1
- package/node/max/max.d.ts +6 -6
- package/node/max/max.js +1 -0
- package/node/min/index.d.ts +1 -1
- package/node/min/index.js +1 -1
- package/node/min/min.d.ts +6 -6
- package/node/min/min.js +1 -0
- package/node/minYearsOld/index.d.ts +1 -1
- package/node/minYearsOld/index.js +1 -1
- package/node/minYearsOld/minYearsOld.d.ts +1 -1
- package/node/mobilePhone/index.d.ts +1 -1
- package/node/mobilePhone/index.js +1 -1
- package/node/number/index.d.ts +1 -1
- package/node/number/index.js +1 -1
- package/node/number/number.d.ts +1 -1
- package/node/object/index.d.ts +1 -1
- package/node/object/index.js +1 -1
- package/node/object/object.d.ts +6 -6
- package/node/object/object.js +6 -4
- package/node/object/objectAsync/objectAsync.d.ts +9 -9
- package/node/object/objectAsync/objectAsync.js +7 -5
- package/node/ogrnIP/index.d.ts +1 -1
- package/node/ogrnIP/index.js +1 -1
- package/node/ogrnUL/index.d.ts +1 -1
- package/node/ogrnUL/index.js +1 -1
- package/node/or/or.js +1 -1
- package/node/partial/partial.d.ts +1 -1
- package/node/passportNumber/passportNumber.js +1 -1
- package/node/pattern/index.d.ts +1 -1
- package/node/pattern/index.js +1 -1
- package/node/rangeDate/rangeDate.d.ts +1 -1
- package/node/rangeDate/rangeDate.js +9 -3
- package/node/rangeDateMinMax/rangeDateMinMax.js +3 -1
- package/node/snils/index.d.ts +1 -1
- package/node/snils/index.js +1 -1
- package/node/snils/snils.js +3 -1
- package/node/string/index.d.ts +1 -1
- package/node/string/index.js +1 -1
- package/node/string/string.d.ts +1 -1
- package/node/string/stringAsync/stringAsync.d.ts +1 -1
- package/node/string/stringAsync/stringAsync.js +1 -1
- package/node/toPlainError/toPlainError.js +1 -4
- package/node/toPlainError/utils/index.d.ts +1 -1
- package/node/toPlainError/utils/index.js +1 -1
- package/node/uploadedFile/index.d.ts +1 -1
- package/node/uploadedFile/index.js +1 -1
- package/node/uploadedFile/uploadedFile.d.ts +1 -1
- package/node/uploadedFileList/index.d.ts +1 -1
- package/node/uploadedFileList/index.js +1 -1
- package/node/uploadedFileList/uploadedFileList.d.ts +1 -1
- package/node/uploadedFileList/uploadedFileList.js +1 -1
- package/number/index.d.ts +1 -1
- package/number/index.js +1 -1
- package/number/number.d.ts +1 -1
- package/object/index.d.ts +1 -1
- package/object/index.js +1 -1
- package/object/object.d.ts +6 -6
- package/object/object.js +6 -4
- package/object/objectAsync/objectAsync.d.ts +9 -9
- package/object/objectAsync/objectAsync.js +7 -5
- package/ogrnIP/index.d.ts +1 -1
- package/ogrnIP/index.js +1 -1
- package/ogrnUL/index.d.ts +1 -1
- package/ogrnUL/index.js +1 -1
- package/or/or.js +1 -1
- package/package.json +1 -1
- package/partial/partial.d.ts +1 -1
- package/passportNumber/passportNumber.js +1 -1
- package/pattern/index.d.ts +1 -1
- package/pattern/index.js +1 -1
- package/rangeDate/rangeDate.d.ts +1 -1
- package/rangeDate/rangeDate.js +9 -3
- package/rangeDateMinMax/rangeDateMinMax.js +3 -1
- package/snils/index.d.ts +1 -1
- package/snils/index.js +1 -1
- package/snils/snils.js +3 -1
- package/string/index.d.ts +1 -1
- package/string/index.js +1 -1
- package/string/string.d.ts +1 -1
- package/string/stringAsync/stringAsync.d.ts +1 -1
- package/string/stringAsync/stringAsync.js +1 -1
- package/toPlainError/toPlainError.js +1 -4
- package/toPlainError/utils/index.d.ts +1 -1
- package/toPlainError/utils/index.js +1 -1
- package/uploadedFile/index.d.ts +1 -1
- package/uploadedFile/index.js +1 -1
- package/uploadedFile/uploadedFile.d.ts +1 -1
- package/uploadedFileList/index.d.ts +1 -1
- package/uploadedFileList/index.js +1 -1
- package/uploadedFileList/uploadedFileList.d.ts +1 -1
- package/uploadedFileList/uploadedFileList.js +1 -1
package/partial/partial.d.ts
CHANGED
@@ -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").
|
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
|
* Проверяет валиден ли номер паспорта
|
package/pattern/index.d.ts
CHANGED
package/pattern/index.js
CHANGED
package/rangeDate/rangeDate.d.ts
CHANGED
@@ -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").
|
49
|
+
export declare const rangeDate: <TLastSchemaValues extends Record<string, unknown>>(...rules: ValidationRule<RangeDateValue, TLastSchemaValues>[]) => import("../core").IGuard<TLastSchemaValues, RangeDateParams>;
|
50
50
|
export {};
|
package/rangeDate/rangeDate.js
CHANGED
@@ -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(
|
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:
|
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:
|
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) =>
|
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
package/snils/index.js
CHANGED
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(
|
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
package/string/index.js
CHANGED
package/string/string.d.ts
CHANGED
@@ -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").
|
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").
|
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;
|
package/uploadedFile/index.d.ts
CHANGED
package/uploadedFile/index.js
CHANGED
@@ -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").
|
30
|
+
export declare const uploadedFile: <TLastSchemeValues extends Record<string, unknown>>(...rules: ValidationRule<UploadFile, TLastSchemeValues>[]) => import("../core").IGuard<TLastSchemeValues, {}>;
|
@@ -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").
|
24
|
+
export declare const uploadedFileList: <TLastSchemeValues extends Record<string, unknown>>(...rules: ValidationRule<UploadFile[], TLastSchemeValues>[]) => import("../core").IGuard<TLastSchemeValues, {}>;
|