@astral/validations 4.24.3 → 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/index.js
CHANGED
@@ -1,54 +1,54 @@
|
|
1
|
-
export {
|
2
|
-
export {
|
3
|
-
export { string, STRING_TYPE_ERROR_INFO, stringAsync } from './string';
|
4
|
-
export { textField, INVALID_TEXT_FIELD_ERROR_INFO, LENGTH_TEXT_FIELD_ERROR_INFO, } from './textField';
|
5
|
-
export { date, INVALID_DATE_ERROR_INFO, DATE_TYPE_ERROR_INFO } from './date';
|
6
|
-
export { number, NAN_NUMBER_ERROR_INFO, NUMBER_TYPE_ERROR_INFO, INFINITY_NUMBER_ERROR_INFO, } from './number';
|
7
|
-
export { boolean, BOOLEAN_TYPE_ERROR_INFO } from './boolean';
|
8
|
-
export { array, ARRAY_TYPE_ERROR_INFO } from './array';
|
1
|
+
export { any } from './any';
|
2
|
+
export { ARRAY_TYPE_ERROR_INFO, array } from './array';
|
9
3
|
export { arrayItem } from './arrayItem';
|
4
|
+
export { BOOLEAN_TYPE_ERROR_INFO, boolean } from './boolean';
|
5
|
+
export { CONTAINS_DIFFERENT_CASES_ERROR_CODE, containsDifferentCases, } from './containsDifferentCases';
|
6
|
+
export { CONTAINS_NUMBERS_ERROR_CODE, containsNumbers, } from './containsNumbers';
|
7
|
+
export { CONTAINS_PUNCTUATION_MARKS_ERROR_CODE, containsPunctuationMarks, } from './containsPunctuationMarks';
|
8
|
+
export { createRule, REQUIRED_ERROR_INFO } from './core';
|
9
|
+
export { DATE_TYPE_ERROR_INFO, date, INVALID_DATE_ERROR_INFO } from './date';
|
10
10
|
export { deepPartial } from './deepPartial';
|
11
|
-
export {
|
12
|
-
export {
|
13
|
-
export {
|
14
|
-
export { max, STRING_MAX_ERROR_CODE, ARRAY_MAX_ERROR_CODE, DATE_MAX_ERROR_CODE, NUMBER_MAX_ERROR_CODE, } from './max';
|
15
|
-
export { integer, INTEGER_ERROR_INFO } from './integer';
|
16
|
-
export { positiveNumber, POSITIVE_NUMBER_ERROR_INFO } from './positiveNumber';
|
17
|
-
export { or } from './or';
|
18
|
-
export { pattern, PATTERN_ERROR_CODE } from './pattern';
|
19
|
-
export { onlyNumber, ONLY_NUMBER_ERROR_CODE } from './onlyNumber';
|
20
|
-
export { containsNumbers, CONTAINS_NUMBERS_ERROR_CODE, } from './containsNumbers';
|
21
|
-
export { containsPunctuationMarks, CONTAINS_PUNCTUATION_MARKS_ERROR_CODE, } from './containsPunctuationMarks';
|
22
|
-
export { containsDifferentCases, CONTAINS_DIFFERENT_CASES_ERROR_CODE, } from './containsDifferentCases';
|
23
|
-
export { toPlainError } from './toPlainError';
|
24
|
-
export { email, LENGTH_EMAIL_ERROR_INFO, INVALID_EMAIL_ERROR_INFO, } from './email';
|
25
|
-
export { emailOrPhone, EMAIL_OR_PHONE_ERROR_INFO } from './emailOrPhone';
|
11
|
+
export { email, INVALID_EMAIL_ERROR_INFO, LENGTH_EMAIL_ERROR_INFO, } from './email';
|
12
|
+
export { EMAIL_OR_PHONE_ERROR_INFO, emailOrPhone } from './emailOrPhone';
|
13
|
+
export { enabled } from './enabled';
|
26
14
|
export { guid, INVALID_GUID_ERROR_INFO } from './guid';
|
15
|
+
export { INN_FL_ERROR_INFO, innFL } from './innFL';
|
16
|
+
export { INN_IP_ERROR_INFO, innIP } from './innIP';
|
17
|
+
export { INN_12_SYMBOLS_ERROR_INFO, innTwelveSymbols, } from './innTwelveSymbols';
|
18
|
+
export { INN_UL_ERROR_INFO, innUL } from './innUL';
|
19
|
+
export { INTEGER_ERROR_INFO, integer } from './integer';
|
20
|
+
export { INVALID_KPP_ERROR_INFO, KPP_DOUBLE_ZERO_START_ERROR_INFO, KPP_ZEROS_ONLY_ERROR_INFO, kpp, } from './kpp';
|
27
21
|
export { length, STRING_LENGTH_ERROR_CODE } from './length';
|
28
|
-
export {
|
29
|
-
export {
|
30
|
-
export {
|
31
|
-
export {
|
32
|
-
export {
|
33
|
-
export {
|
34
|
-
export {
|
35
|
-
export {
|
36
|
-
export {
|
37
|
-
export {
|
38
|
-
export {
|
39
|
-
export {
|
40
|
-
export {
|
41
|
-
export {
|
42
|
-
export {
|
43
|
-
export {
|
44
|
-
export {
|
45
|
-
export {
|
22
|
+
export { ARRAY_MAX_ERROR_CODE, DATE_MAX_ERROR_CODE, max, NUMBER_MAX_ERROR_CODE, STRING_MAX_ERROR_CODE, } from './max';
|
23
|
+
export { ARRAY_MIN_ERROR_CODE, DATE_MIN_ERROR_CODE, min, NUMBER_MIN_ERROR_CODE, STRING_MIN_ERROR_CODE, } from './min';
|
24
|
+
export { BIRTH_DATE_MAX_ERROR_CODE, BIRTH_DATE_MIN_ERROR_CODE, minYearsOld, } from './minYearsOld';
|
25
|
+
export { MOBILE_PHONE_ERROR_INFO, mobilePhone } from './mobilePhone';
|
26
|
+
export { INFINITY_NUMBER_ERROR_INFO, NAN_NUMBER_ERROR_INFO, NUMBER_TYPE_ERROR_INFO, number, } from './number';
|
27
|
+
export { OBJECT_TYPE_ERROR_INFO, object, objectAsync, } from './object';
|
28
|
+
export { OGRN_IP_ERROR_INFO, ogrnIP } from './ogrnIP';
|
29
|
+
export { OGRN_UL_ERROR_INFO, ogrnUL } from './ogrnUL';
|
30
|
+
export { ONLY_NUMBER_ERROR_CODE, onlyNumber } from './onlyNumber';
|
31
|
+
export { optional, optionalAsync } from './optional';
|
32
|
+
export { or } from './or';
|
33
|
+
export { partial } from './partial';
|
34
|
+
export { PASSPORT_CODE_ERROR_INFO, PASSPORT_CODE_LENGTH_ERROR_INFO, PASSPORT_CODE_ONLY_DIGITS_ERROR_INFO, passportCode, } from './passportCode';
|
35
|
+
export { PASSPORT_NUMBER_ERROR_INFO, PASSPORT_NUMBER_LENGTH_ERROR_INFO, PASSPORT_NUMBER_ONLY_DIGITS_ERROR_INFO, passportNumber, } from './passportNumber';
|
36
|
+
export { PASSPORT_SERIES_ERROR_INFO, PASSPORT_SERIES_ERROR_LENGTH_INFO, PASSPORT_SERIES_ONLY_DIGITS_ERROR_INFO, passportSeries, } from './passportSeries';
|
37
|
+
export { PATTERN_ERROR_CODE, pattern } from './pattern';
|
38
|
+
export { PERSON_NAME_ERROR_INFO, personName } from './personName';
|
39
|
+
export { PERSON_PATRONYMIC_ERROR_INFO, personPatronymic, } from './personPatronymic';
|
40
|
+
export { PERSON_SURNAME_ERROR_INFO, personSurname } from './personSurname';
|
41
|
+
export { POSITIVE_NUMBER_ERROR_INFO, positiveNumber } from './positiveNumber';
|
42
|
+
export { RANGE_DATE_END_EARLIER_START_ERROR_INFO, RANGE_DATE_END_INVALID_ERROR_INFO, RANGE_DATE_END_REQUIRED_ERROR_INFO, RANGE_DATE_REQUIRED_ERROR_INFO, RANGE_DATE_START_INVALID_ERROR_INFO, RANGE_DATE_START_REQUIRED_ERROR_INFO, rangeDate, } from './rangeDate';
|
43
|
+
export { RANGE_DATE_INTERVAL_ERROR_INFO, rangeDateInterval, } from './rangeDateInterval';
|
44
|
+
export { RANGE_DATE_MAX_ERROR_INFO, RANGE_DATE_MIN_ERROR_INFO, rangeDateMinMax, } from './rangeDateMinMax';
|
45
|
+
export { RANGE_DATE_NOT_EQUAL_ERROR_INFO, rangeDateNotEqual, } from './rangeDateNotEqual';
|
46
|
+
export { SNILS_ERROR_INFO, snils } from './snils';
|
47
|
+
export { STRING_TYPE_ERROR_INFO, string, stringAsync } from './string';
|
48
|
+
export { INVALID_TEXT_FIELD_ERROR_INFO, LENGTH_TEXT_FIELD_ERROR_INFO, textField, } from './textField';
|
49
|
+
export { toPlainError } from './toPlainError';
|
46
50
|
export { toPrettyError } from './toPrettyError';
|
47
51
|
export { transform } from './transform';
|
48
|
-
export {
|
49
|
-
export {
|
50
|
-
export {
|
51
|
-
export { rangeDateMinMax, RANGE_DATE_MAX_ERROR_INFO, RANGE_DATE_MIN_ERROR_INFO, } from './rangeDateMinMax';
|
52
|
-
export { rangeDateNotEqual, RANGE_DATE_NOT_EQUAL_ERROR_INFO, } from './rangeDateNotEqual';
|
53
|
-
export { uploadedFile, FILE_UPLOAD_ERROR_INFO, FILE_LOADING_ERROR_INFO, FILE_REQUIRED_ERROR_INFO, FILE_RESTRICTION_ERROR_INFO, } from './uploadedFile';
|
54
|
-
export { uploadedFileList, FILE_LIST_NOT_ARRAY_ERROR_INFO, } from './uploadedFileList';
|
52
|
+
export { FILE_LOADING_ERROR_INFO, FILE_REQUIRED_ERROR_INFO, FILE_RESTRICTION_ERROR_INFO, FILE_UPLOAD_ERROR_INFO, uploadedFile, } from './uploadedFile';
|
53
|
+
export { FILE_LIST_NOT_ARRAY_ERROR_INFO, uploadedFileList, } from './uploadedFileList';
|
54
|
+
export { when } from './when';
|
package/innFL/index.d.ts
CHANGED
package/innFL/index.js
CHANGED
package/innIP/index.d.ts
CHANGED
package/innIP/index.js
CHANGED
package/innUL/index.d.ts
CHANGED
package/innUL/index.js
CHANGED
package/length/index.d.ts
CHANGED
package/length/index.js
CHANGED
package/max/index.d.ts
CHANGED
package/max/index.js
CHANGED
package/max/max.d.ts
CHANGED
@@ -1,11 +1,11 @@
|
|
1
|
-
import { type ValidationContext
|
2
|
-
type BaseMaxValidationTypes = number | string |
|
1
|
+
import { createRule, type ValidationContext } from '../core';
|
2
|
+
type BaseMaxValidationTypes = number | string | unknown[];
|
3
3
|
type CommonThreshold = number | Date;
|
4
|
-
type MaxParams<
|
4
|
+
type MaxParams<TValidationType> = {
|
5
5
|
/**
|
6
6
|
* Сообщение ошибки
|
7
7
|
*/
|
8
|
-
getMessage?: (threshold: CommonThreshold, value:
|
8
|
+
getMessage?: (threshold: CommonThreshold, value: TValidationType, ctx: ValidationContext) => string;
|
9
9
|
};
|
10
10
|
/**
|
11
11
|
* Проверяет значение на соответствие максимуму. Работает с: string, array, Date, number
|
@@ -21,6 +21,6 @@ type MaxParams<ValidationType> = {
|
|
21
21
|
* date(max(new Date())));
|
22
22
|
* ```
|
23
23
|
*/
|
24
|
-
export declare function max<
|
25
|
-
export declare function max<
|
24
|
+
export declare function max<TValidationType extends Date, TLastSchemaValues extends Record<string, unknown> = {}>(threshold: Date, params?: MaxParams<TValidationType>): ReturnType<typeof createRule<Date, TLastSchemaValues>>;
|
25
|
+
export declare function max<TValidationType extends BaseMaxValidationTypes, TLastSchemaValues extends Record<string, unknown> = {}>(threshold: number, params?: MaxParams<TValidationType>): ReturnType<typeof createRule<BaseMaxValidationTypes, TLastSchemaValues>>;
|
26
26
|
export {};
|
package/max/max.js
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
import { createRule, resetTime } from '../core';
|
2
2
|
import { ARRAY_MAX_ERROR_CODE, DATE_MAX_ERROR_CODE, NUMBER_MAX_ERROR_CODE, STRING_MAX_ERROR_CODE, } from './constants';
|
3
3
|
export function max(threshold, params) {
|
4
|
+
// biome-ignore lint/complexity/noExcessiveCognitiveComplexity: <>
|
4
5
|
return createRule((value, ctx) => {
|
5
6
|
const getMessage = (typeMessage) => (params === null || params === void 0 ? void 0 : params.getMessage)
|
6
7
|
? params.getMessage(threshold, value, ctx)
|
package/min/index.d.ts
CHANGED
package/min/index.js
CHANGED
package/min/min.d.ts
CHANGED
@@ -1,11 +1,11 @@
|
|
1
|
-
import { type ValidationContext
|
2
|
-
type BaseMinValidationTypes = number | string |
|
1
|
+
import { createRule, type ValidationContext } from '../core';
|
2
|
+
type BaseMinValidationTypes = number | string | unknown[];
|
3
3
|
type CommonThreshold = number | Date;
|
4
|
-
type MinParams<
|
4
|
+
type MinParams<TValidationType> = {
|
5
5
|
/**
|
6
6
|
* Сообщение ошибки
|
7
7
|
*/
|
8
|
-
getMessage?: (threshold: CommonThreshold, value:
|
8
|
+
getMessage?: (threshold: CommonThreshold, value: TValidationType, ctx: ValidationContext) => string;
|
9
9
|
};
|
10
10
|
/**
|
11
11
|
* Проверяет значение на соответствие минимуму. Работает с: string, array, Date, number
|
@@ -21,6 +21,6 @@ type MinParams<ValidationType> = {
|
|
21
21
|
* date(min(new Date())));
|
22
22
|
* ```
|
23
23
|
*/
|
24
|
-
export declare function min<
|
25
|
-
export declare function min<
|
24
|
+
export declare function min<TValidationType extends Date, TLastSchemaValues extends Record<string, unknown> = {}>(threshold: Date, params?: MinParams<TValidationType>): ReturnType<typeof createRule<Date, TLastSchemaValues>>;
|
25
|
+
export declare function min<TValidationType extends BaseMinValidationTypes, TLastSchemaValues extends Record<string, unknown> = {}>(threshold: number, params?: MinParams<TValidationType>): ReturnType<typeof createRule<BaseMinValidationTypes, TLastSchemaValues>>;
|
26
26
|
export {};
|
package/min/min.js
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
import { createRule, resetTime } from '../core';
|
2
2
|
import { ARRAY_MIN_ERROR_CODE, DATE_MIN_ERROR_CODE, NUMBER_MIN_ERROR_CODE, STRING_MIN_ERROR_CODE, } from './constants';
|
3
3
|
export function min(threshold, params) {
|
4
|
+
// biome-ignore lint/complexity/noExcessiveCognitiveComplexity: <>
|
4
5
|
return createRule((value, ctx) => {
|
5
6
|
const getMessage = (typeMessage) => (params === null || params === void 0 ? void 0 : params.getMessage)
|
6
7
|
? params.getMessage(threshold, value, ctx)
|
package/minYearsOld/index.d.ts
CHANGED
package/minYearsOld/index.js
CHANGED
@@ -20,5 +20,5 @@ type MinYearsOldParams = {
|
|
20
20
|
* );
|
21
21
|
* ```
|
22
22
|
*/
|
23
|
-
export declare function minYearsOld<
|
23
|
+
export declare function minYearsOld<TValidationType, TLastSchemaValues extends Record<string, unknown> = {}>(age: number, params?: MinYearsOldParams): (value: TValidationType, prevCtx?: import("../core").ValidationContext<TLastSchemaValues> | undefined) => ReturnType<import("../core").IndependentValidationRule<TValidationType, TLastSchemaValues>>;
|
24
24
|
export {};
|
package/mobilePhone/index.d.ts
CHANGED
package/mobilePhone/index.js
CHANGED
package/node/array/array.d.ts
CHANGED
@@ -12,4 +12,4 @@ import { type ValidationRule, type ValidationTypes } from '../core';
|
|
12
12
|
* validateArray(value);
|
13
13
|
* ```
|
14
14
|
*/
|
15
|
-
export declare const array: <TItem extends ValidationTypes, TLastSchemaValues extends Record<string, unknown> = {}>(...rules: ValidationRule<
|
15
|
+
export declare const array: <TItem extends ValidationTypes, TLastSchemaValues extends Record<string, unknown> = {}>(...rules: ValidationRule<TItem[], TLastSchemaValues>[]) => import("../core").IGuard<TLastSchemaValues, {}>;
|
@@ -10,4 +10,4 @@ import { type ValidationRule } from '../core';
|
|
10
10
|
* validate(true);
|
11
11
|
* ```
|
12
12
|
*/
|
13
|
-
export declare const boolean: <TLastSchemaValues extends Record<string, unknown>>(...rules: ValidationRule<boolean, TLastSchemaValues>[]) => import("../core").
|
13
|
+
export declare const boolean: <TLastSchemaValues extends Record<string, unknown>>(...rules: ValidationRule<boolean, TLastSchemaValues>[]) => import("../core").IGuard<TLastSchemaValues, {}>;
|
@@ -12,7 +12,7 @@ const constants_1 = require("./constants");
|
|
12
12
|
* ```
|
13
13
|
*/
|
14
14
|
const containsPunctuationMarks = (params) => (0, core_1.createRule)((value, ctx) => {
|
15
|
-
const containsPunctuationMarksRegex = /(?=.*[!$%&’”'"()
|
15
|
+
const containsPunctuationMarksRegex = /(?=.*[!$%&’”'"()+,-./:;<=>?@[\]^_{|}])/;
|
16
16
|
if (!containsPunctuationMarksRegex.test(value)) {
|
17
17
|
return ctx.createError({
|
18
18
|
code: constants_1.CONTAINS_PUNCTUATION_MARKS_ERROR_CODE,
|
@@ -3,4 +3,4 @@ import { type IndependentValidationRule, type ValidationRule } from '../rule';
|
|
3
3
|
* Объединяет переданные правила в цепочку правил, останавливает выполнение цепочки, если появилась ошибка. Выполняет правила слева направо
|
4
4
|
* @example compose(min(), max());
|
5
5
|
*/
|
6
|
-
export declare const compose: <
|
6
|
+
export declare const compose: <TValidationType, TLastSchemaValues extends Record<string, unknown>>(...rules: Array<IndependentValidationRule<TValidationType, TLastSchemaValues> | ValidationRule<TValidationType, TLastSchemaValues>>) => IndependentValidationRule<TValidationType, Record<string, unknown>>;
|
@@ -3,4 +3,4 @@ import { type AsyncIndependentValidationRule, type AsyncValidationRule, type Ind
|
|
3
3
|
* Объединяет переданные асинхронные правила в цепочку правил, останавливает выполнение цепочки, если появилась ошибка. Выполняет правила слева направо
|
4
4
|
* @example composeAsync(stringAsync(), max());
|
5
5
|
*/
|
6
|
-
export declare const composeAsync: <
|
6
|
+
export declare const composeAsync: <TValidationType, TLastSchemaValues extends Record<string, unknown>>(...rules: Array<IndependentValidationRule<TValidationType, TLastSchemaValues> | AsyncIndependentValidationRule<TValidationType, TLastSchemaValues> | ValidationRule<TValidationType, TLastSchemaValues> | AsyncValidationRule<TValidationType, TLastSchemaValues>>) => AsyncIndependentValidationRule<TValidationType, Record<string, unknown>>;
|
@@ -1,6 +1,6 @@
|
|
1
1
|
import { type DeepPartial } from 'utility-types';
|
2
|
-
import { type ValidationContext } from '../types';
|
3
2
|
import { type ValidationTypes } from '../../types';
|
3
|
+
import { type ValidationContext } from '../types';
|
4
4
|
type Params<TLastSchemaValues extends Record<string, unknown>> = {
|
5
5
|
/**
|
6
6
|
* Value последнего валидируемого объекта
|
@@ -8,7 +8,7 @@ export type ValidationArrayErrorCause = {
|
|
8
8
|
* Массив ошибок элементов валидируемого массива.
|
9
9
|
* Индекс errorArray соответвует индексу валидируемого элемента массива
|
10
10
|
*/
|
11
|
-
errorArray:
|
11
|
+
errorArray: ValidationResult[];
|
12
12
|
};
|
13
13
|
/**
|
14
14
|
* Array ошибок для массива
|
@@ -1,5 +1,5 @@
|
|
1
|
-
import { type ValidationErrorData, ValidationSimpleError } from '../SimpleError';
|
2
1
|
import { type ValidationResult } from '../../types';
|
2
|
+
import { type ValidationErrorData, ValidationSimpleError } from '../SimpleError';
|
3
3
|
/**
|
4
4
|
* Map, которое содержит результат валидации свойств
|
5
5
|
*/
|
@@ -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("./ErrorMap"), exports);
|
18
17
|
__exportStar(require("./createErrorMap"), exports);
|
18
|
+
__exportStar(require("./ErrorMap"), exports);
|
@@ -2,15 +2,15 @@ import { type ErrorCode } from '../types';
|
|
2
2
|
/**
|
3
3
|
* Причина ошибки валидации
|
4
4
|
*/
|
5
|
-
export type ValidationErrorData<
|
6
|
-
cause:
|
5
|
+
export type ValidationErrorData<TAddCause extends Record<string, unknown>> = {
|
6
|
+
cause: TAddCause & {
|
7
7
|
code: ErrorCode;
|
8
8
|
};
|
9
9
|
};
|
10
10
|
/**
|
11
11
|
* Простая ошибка правил валидации. Не имеет вложенных ошибок
|
12
12
|
*/
|
13
|
-
export declare class ValidationSimpleError<
|
14
|
-
cause: ValidationErrorData<
|
15
|
-
constructor(message: string, data: ValidationErrorData<
|
13
|
+
export declare class ValidationSimpleError<TAddCause extends Record<string, unknown> = {}> extends Error {
|
14
|
+
cause: ValidationErrorData<TAddCause>['cause'];
|
15
|
+
constructor(message: string, data: ValidationErrorData<TAddCause>);
|
16
16
|
}
|
@@ -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("./SimpleError"), exports);
|
18
17
|
__exportStar(require("./createSimpleError"), exports);
|
18
|
+
__exportStar(require("./SimpleError"), exports);
|
@@ -1,6 +1,6 @@
|
|
1
|
-
export * from './SimpleError';
|
2
1
|
export * from './ArrayError';
|
2
|
+
export * from './constants';
|
3
|
+
export * from './createErrorCode';
|
3
4
|
export * from './ErrorMap';
|
5
|
+
export * from './SimpleError';
|
4
6
|
export * from './types';
|
5
|
-
export * from './createErrorCode';
|
6
|
-
export * from './constants';
|
@@ -14,9 +14,9 @@ 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("./SimpleError"), exports);
|
18
17
|
__exportStar(require("./ArrayError"), exports);
|
18
|
+
__exportStar(require("./constants"), exports);
|
19
|
+
__exportStar(require("./createErrorCode"), exports);
|
19
20
|
__exportStar(require("./ErrorMap"), exports);
|
21
|
+
__exportStar(require("./SimpleError"), exports);
|
20
22
|
__exportStar(require("./types"), exports);
|
21
|
-
__exportStar(require("./createErrorCode"), exports);
|
22
|
-
__exportStar(require("./constants"), exports);
|
@@ -1,6 +1,6 @@
|
|
1
|
+
import { type ValidationArrayError } from './ArrayError';
|
1
2
|
import { type ValidationErrorMap } from './ErrorMap';
|
2
3
|
import { type ValidationSimpleError } from './SimpleError';
|
3
|
-
import { type ValidationArrayError } from './ArrayError';
|
4
4
|
/**
|
5
5
|
* Уникальный код ошибки валидации
|
6
6
|
*/
|
@@ -1,6 +1,6 @@
|
|
1
|
-
import { type ValidationResult } from '../../types';
|
2
1
|
import { type ValidationContext } from '../../context';
|
3
|
-
|
2
|
+
import { type ValidationResult } from '../../types';
|
3
|
+
export type GuardDefOptions<TAddDefOptions extends Record<string, unknown>> = Partial<TAddDefOptions> & {
|
4
4
|
/**
|
5
5
|
* Переопределяет дефолтное сообщения ошибки для required
|
6
6
|
* @example string.define({ requiredMessage: 'ИНН не может быть пустым' })(inn())
|
@@ -21,35 +21,35 @@ export type GuardValue = unknown;
|
|
21
21
|
/**
|
22
22
|
* Интерфейс функции guard, которая в прототипе содержит метод define
|
23
23
|
*/
|
24
|
-
export interface
|
24
|
+
export interface IGuard<TLastSchemaValues extends Record<string, unknown> = {}, TAddDefOptions extends Record<string, unknown> = {}> {
|
25
25
|
(value: GuardValue, ctx?: ValidationContext<TLastSchemaValues>): ValidationResult;
|
26
26
|
/**
|
27
27
|
* Функция для создания нового guard с переопределенными дефолтными параметрами. Возвращает новый guard
|
28
28
|
* @param options - параметры, позволяющие переопределить дефолтные настройки guard
|
29
29
|
* @example string(inn()).define({ requiredMessage: 'ИНН не может быть пустым' })
|
30
30
|
*/
|
31
|
-
define<TDefineLastSchemaValues extends Record<string, unknown> = {}>(options: GuardDefOptions<
|
31
|
+
define<TDefineLastSchemaValues extends Record<string, unknown> = {}>(options: GuardDefOptions<TAddDefOptions>): IGuard<TDefineLastSchemaValues, TAddDefOptions>;
|
32
32
|
}
|
33
33
|
/**
|
34
34
|
* Интерфейс асинхронной функции guard, которая в прототипе содержит метод define
|
35
35
|
*/
|
36
|
-
export interface
|
36
|
+
export interface IAsyncGuard<TLastSchemaValues extends Record<string, unknown> = {}, TAddDefOptions extends Record<string, unknown> = {}> {
|
37
37
|
(value: GuardValue, ctx?: ValidationContext<TLastSchemaValues>): Promise<ValidationResult>;
|
38
38
|
/**
|
39
39
|
* Функция для создания нового guard с переопределенными дефолтными параметрами. Возвращает новый guard
|
40
40
|
* @param options - параметры, позволяющие переопределить дефолтные настройки guard
|
41
41
|
* @example string.define({ requiredMessage: 'ИНН не может быть пустым' })(inn())
|
42
42
|
*/
|
43
|
-
define(options: GuardDefOptions<
|
43
|
+
define(options: GuardDefOptions<TAddDefOptions>): IAsyncGuard<TLastSchemaValues, TAddDefOptions>;
|
44
44
|
}
|
45
45
|
/**
|
46
46
|
* Функция, которая позволяет определять частную логику для guard
|
47
47
|
*/
|
48
|
-
type GuardExecutor<TLastSchemaValues extends Record<string, unknown>,
|
48
|
+
type GuardExecutor<TLastSchemaValues extends Record<string, unknown>, TAddDefOptions extends Record<string, unknown>> = (value: unknown, ctx: ValidationContext<TLastSchemaValues>, defOptions: GuardDefOptions<TAddDefOptions>) => ValidationResult;
|
49
49
|
/**
|
50
50
|
* Функция, которая позволяет определять частную логику для guard
|
51
51
|
*/
|
52
|
-
type AsyncGuardExecutor<TLastSchemaValues extends Record<string, unknown>,
|
52
|
+
type AsyncGuardExecutor<TLastSchemaValues extends Record<string, unknown>, TAddDefOptions extends Record<string, unknown>> = (value: unknown, ctx: ValidationContext<TLastSchemaValues>, defOptions: GuardDefOptions<TAddDefOptions>) => Promise<ValidationResult>;
|
53
53
|
/**
|
54
54
|
* Создает guard. Guard - функция, проверяющая тип значения
|
55
55
|
* По-дефолту проверяет value на required. Для выключения required необходимо использовать optional().
|
@@ -66,6 +66,6 @@ type AsyncGuardExecutor<TLastSchemaValues extends Record<string, unknown>, AddDe
|
|
66
66
|
* });
|
67
67
|
* ```
|
68
68
|
*/
|
69
|
-
export declare function createGuard<TLastSchemaValues extends Record<string, unknown>,
|
70
|
-
export declare function createGuard<TLastSchemaValues extends Record<string, unknown>,
|
69
|
+
export declare function createGuard<TLastSchemaValues extends Record<string, unknown>, TAddDefOptions extends Record<string, unknown> = {}>(executor: GuardExecutor<TLastSchemaValues, TAddDefOptions>): IGuard<TLastSchemaValues, TAddDefOptions>;
|
70
|
+
export declare function createGuard<TLastSchemaValues extends Record<string, unknown>, TAddDefOptions extends Record<string, unknown> = {}>(executor: AsyncGuardExecutor<TLastSchemaValues, TAddDefOptions>): IAsyncGuard<TLastSchemaValues, TAddDefOptions>;
|
71
71
|
export {};
|
@@ -1,8 +1,8 @@
|
|
1
1
|
"use strict";
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
3
|
exports.createGuard = createGuard;
|
4
|
-
const rule_1 = require("../../rule");
|
5
4
|
const context_1 = require("../../context");
|
5
|
+
const rule_1 = require("../../rule");
|
6
6
|
function createGuard(executor) {
|
7
7
|
// выделено в отдельную именованную функцию для того, чтобы ее можно было рекурсивно вызывать в define
|
8
8
|
const createInnerGuard = (defOptions = {}) => {
|
package/node/core/index.d.ts
CHANGED
@@ -1,9 +1,9 @@
|
|
1
|
-
export * from './
|
2
|
-
export * from './
|
1
|
+
export * from './compose';
|
2
|
+
export * from './composeAsync';
|
3
3
|
export * from './context';
|
4
4
|
export * from './errors';
|
5
|
+
export * from './errors';
|
5
6
|
export * from './guard';
|
6
7
|
export * from './rule';
|
7
|
-
export * from './
|
8
|
-
export * from './composeAsync';
|
8
|
+
export * from './types';
|
9
9
|
export * from './utils';
|
package/node/core/index.js
CHANGED
@@ -14,12 +14,12 @@ 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("./
|
18
|
-
__exportStar(require("./
|
17
|
+
__exportStar(require("./compose"), exports);
|
18
|
+
__exportStar(require("./composeAsync"), exports);
|
19
19
|
__exportStar(require("./context"), exports);
|
20
20
|
__exportStar(require("./errors"), exports);
|
21
|
+
__exportStar(require("./errors"), exports);
|
21
22
|
__exportStar(require("./guard"), exports);
|
22
23
|
__exportStar(require("./rule"), exports);
|
23
|
-
__exportStar(require("./
|
24
|
-
__exportStar(require("./composeAsync"), exports);
|
24
|
+
__exportStar(require("./types"), exports);
|
25
25
|
__exportStar(require("./utils"), exports);
|
@@ -1,6 +1,6 @@
|
|
1
|
-
import { type AsyncValidationRule, type ValidationRule } from '../types';
|
2
|
-
import { type ValidationResult } from '../../types';
|
3
1
|
import { type ValidationContext } from '../../context';
|
2
|
+
import { type ValidationResult } from '../../types';
|
3
|
+
import { type AsyncValidationRule, type ValidationRule } from '../types';
|
4
4
|
/**
|
5
5
|
* Позволяет рекурсивно вызывать асинхронные правила. Rule может возвращать другой rule
|
6
6
|
* Если один из rule выбросит exception, то функция его обработает и вернет дефолтную ошибку
|
@@ -1,6 +1,6 @@
|
|
1
|
-
import { type ValidationRule } from '../types';
|
2
|
-
import { type ValidationResult } from '../../types';
|
3
1
|
import { type ValidationContext } from '../../context';
|
2
|
+
import { type ValidationResult } from '../../types';
|
3
|
+
import { type ValidationRule } from '../types';
|
4
4
|
/**
|
5
5
|
* Позволяет рекурсивно вызывать правила. Rule может возвращать другой rule
|
6
6
|
*/
|