@astral/validations 4.14.0 → 4.14.1
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/core/compose/compose.d.ts +1 -1
- package/core/composeAsync/composeAsync.d.ts +1 -1
- package/core/rule/createRule/createRule.d.ts +1 -1
- package/core/rule/required/required.d.ts +1 -1
- package/deepPartial/deepPartial.d.ts +1 -1
- package/object/objectAsync/objectAsync.js +1 -1
- package/package.json +1 -1
- package/string/stringAsync/stringAsync.d.ts +1 -1
- package/string/stringAsync/stringAsync.js +1 -1
package/array/array.d.ts
CHANGED
@@ -12,4 +12,4 @@ import { type ValidationRule } from '../core';
|
|
12
12
|
* validateArray(value);
|
13
13
|
* ```
|
14
14
|
*/
|
15
|
-
export declare const array: <TItem extends unknown, TLastSchemaValues extends Record<string, unknown> = {}>(...rules: ValidationRule<TItem
|
15
|
+
export declare const array: <TItem extends unknown, TLastSchemaValues extends Record<string, unknown> = {}>(...rules: ValidationRule<Array<TItem>, TLastSchemaValues>[]) => import("../core").Guard<TLastSchemaValues, {}>;
|
@@ -3,4 +3,4 @@ import { type IndependentValidationRule, type ValidationRule } from '../rule';
|
|
3
3
|
* @description Объединяет переданные правила в цепочку правил, останавливает выполнение цепочки, если появилась ошибка. Выполняет правила слева направо
|
4
4
|
* @example compose(min(), max());
|
5
5
|
*/
|
6
|
-
export declare const compose: <ValidationType, TLastSchemaValues extends Record<string, unknown>>(...rules:
|
6
|
+
export declare const compose: <ValidationType, TLastSchemaValues extends Record<string, unknown>>(...rules: Array<IndependentValidationRule<ValidationType, TLastSchemaValues> | ValidationRule<ValidationType, TLastSchemaValues>>) => IndependentValidationRule<ValidationType, 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: <ValidationType, TLastSchemaValues extends Record<string, unknown>>(...rules:
|
6
|
+
export declare const composeAsync: <ValidationType, TLastSchemaValues extends Record<string, unknown>>(...rules: Array<IndependentValidationRule<ValidationType, TLastSchemaValues> | AsyncIndependentValidationRule<ValidationType, TLastSchemaValues> | ValidationRule<ValidationType, TLastSchemaValues> | AsyncValidationRule<ValidationType, TLastSchemaValues>>) => AsyncIndependentValidationRule<ValidationType, Record<string, unknown>>;
|
@@ -30,5 +30,5 @@ type RuleExecutor<ValidationType extends ValidationTypes, TLastSchemaValues exte
|
|
30
30
|
* }, params);
|
31
31
|
* ```
|
32
32
|
*/
|
33
|
-
export declare const createRule: <ValidationType extends unknown, TLastSchemaValues extends Record<string, unknown> = {}>(executor: RuleExecutor<ValidationType, TLastSchemaValues>, commonParams?: CommonRuleParams<ValidationType>
|
33
|
+
export declare const createRule: <ValidationType extends unknown, TLastSchemaValues extends Record<string, unknown> = {}>(executor: RuleExecutor<ValidationType, TLastSchemaValues>, commonParams?: CommonRuleParams<ValidationType>) => (value: Parameters<IndependentValidationRule<ValidationType, TLastSchemaValues>>[0], prevCtx?: Parameters<IndependentValidationRule<ValidationType, TLastSchemaValues>>[1]) => ReturnType<IndependentValidationRule<ValidationType, TLastSchemaValues>>;
|
34
34
|
export {};
|
@@ -7,5 +7,5 @@ export declare const required: ({ message, }?: {
|
|
7
7
|
* @description Кастомное сообщение ошибки
|
8
8
|
* @default Обязательно
|
9
9
|
*/
|
10
|
-
message?: string
|
10
|
+
message?: string;
|
11
11
|
}) => (value: unknown, prevCtx?: import("../..").ValidationContext<{}> | undefined) => import("../..").ValidationResult;
|
@@ -18,4 +18,4 @@ import { type Guard } from '../core';
|
|
18
18
|
* const result = validate({ info: { info: {} } });
|
19
19
|
* ```
|
20
20
|
*/
|
21
|
-
export declare const deepPartial: <TLastSchemaValues extends Record<string, unknown>>(guard: Guard<TLastSchemaValues
|
21
|
+
export declare const deepPartial: <TLastSchemaValues extends Record<string, unknown>>(guard: Guard<TLastSchemaValues>) => (value: unknown, prevCtx?: import("../core").ValidationContext<TLastSchemaValues> | undefined) => import("../core").ValidationResult;
|
@@ -44,7 +44,7 @@ import { OBJECT_TYPE_ERROR_INFO } from '../constants';
|
|
44
44
|
* });
|
45
45
|
* ```
|
46
46
|
*/
|
47
|
-
export const objectAsync = (schema) => createGuard((
|
47
|
+
export const objectAsync = (schema) => createGuard((value_1, ctx_1, _a) => __awaiter(void 0, [value_1, ctx_1, _a], void 0, function* (value, ctx, { typeErrorMessage, isPartial }) {
|
48
48
|
const context = createContext(ctx, value, {
|
49
49
|
lastSchemaValue: value,
|
50
50
|
});
|
package/package.json
CHANGED
@@ -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:
|
6
|
+
export declare const stringAsync: <TLastSchemaValues extends Record<string, unknown>>(...rules: Array<ValidationRule<string, TLastSchemaValues> | AsyncValidationRule<string, TLastSchemaValues>>) => import("../../core").AsyncGuard<TLastSchemaValues, {}>;
|
@@ -15,7 +15,7 @@ import { STRING_TYPE_ERROR_INFO } from '../constants';
|
|
15
15
|
* Позволяет использовать для валидации асинхронные правила
|
16
16
|
* @example stringAsync(async () => undefined)
|
17
17
|
*/
|
18
|
-
export const stringAsync = (...rules) => createGuard((
|
18
|
+
export const stringAsync = (...rules) => createGuard((value_1, ctx_1, _a) => __awaiter(void 0, [value_1, ctx_1, _a], void 0, function* (value, ctx, { typeErrorMessage }) {
|
19
19
|
if (!isString(value)) {
|
20
20
|
return ctx.createError(Object.assign(Object.assign({}, STRING_TYPE_ERROR_INFO), { message: typeErrorMessage || STRING_TYPE_ERROR_INFO.message }));
|
21
21
|
}
|