Skip to content

Commit cd4090e

Browse files
committed
feat(unstable): errors proccesing updates
1 parent 11c8a81 commit cd4090e

File tree

7 files changed

+335
-150
lines changed

7 files changed

+335
-150
lines changed

src/lib/unstable/core/SchemaRendererServiceField/types.ts

Lines changed: 74 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,23 @@
11
import type {ErrorObject, ValidateFunction} from 'ajv';
22
import type {FieldValidator} from 'final-form';
33

4-
import type {SetValidationCacheMutator, SetValidationWaitersMutator} from '../mutators';
4+
import type {ARRAY_AND_OBJECT_ERRORS} from '../constants';
55
import type {
6+
ErrorsState,
7+
SetValidationCacheMutator,
8+
SetValidationWaitersMutator,
9+
ValidationState,
10+
ValidationWaiter,
11+
} from '../mutators';
12+
import type {
13+
AsyncValidateError,
614
ErrorMessages,
715
FieldValue,
816
JsonSchema,
17+
ObjectValue,
918
SchemaRendererConfig,
1019
SchemaToValueType,
20+
SyncValidateError,
1121
Validator,
1222
} from '../types';
1323

@@ -31,13 +41,75 @@ export interface GetAjvValidateReturn extends ValidateFunction {
3141

3242
export interface GetAjvErrorMessageParams {
3343
ajvErrorMessage?: string;
34-
errorMessages?: ErrorMessages;
44+
errorMessages: ErrorMessages | undefined;
3545
instancePath: string;
3646
keyword: string;
3747
mainSchema: JsonSchema;
3848
schemaPath: string;
3949
}
4050

51+
export interface ValidateErrorItem {
52+
error: SyncValidateError;
53+
path: string[];
54+
}
55+
56+
export interface ProcessEntityParametesErrorParams {
57+
allValues: ObjectValue;
58+
error: EntityParametersError;
59+
headName: string;
60+
onAsyncError: (asyncError: {
61+
instancePath: string;
62+
params: EntityParametersError['params'];
63+
promise: AsyncValidateError;
64+
}) => void;
65+
onError: (error: ValidateErrorItem) => void;
66+
validationState: ValidationState | undefined;
67+
}
68+
69+
export interface ProcessAjvErrorParams<Schema extends JsonSchema> {
70+
error: ErrorObject;
71+
errorMessages?: ErrorMessages;
72+
headName: string;
73+
mainSchema: Schema;
74+
onError: (error: ValidateErrorItem) => void;
75+
}
76+
77+
export interface ProcessAjvValidateErrorsParams<Schema extends JsonSchema> {
78+
ajvValidateErrors: (ErrorObject | EntityParametersError)[];
79+
allValues: ObjectValue;
80+
errorMessages: ErrorMessages | undefined;
81+
headName: string;
82+
mainSchema: Schema;
83+
serviceFieldName: string;
84+
setValidationCache: SetValidationCacheMutator;
85+
validationState: ValidationState | undefined;
86+
}
87+
88+
export interface ProcessAjvValidateErrorsReturn {
89+
ajvErrorItems: ValidateErrorItem[];
90+
entityParametersErrorItems: ValidateErrorItem[];
91+
waiters: Record<string, ValidationWaiter>;
92+
}
93+
94+
export interface ProcessErrorsStateParams {
95+
errorsState: ErrorsState | undefined;
96+
}
97+
98+
export interface ProcessErrorsStateReturn {
99+
externalPriorityErrorItems: ValidateErrorItem[];
100+
externalRegularErrorItems: ValidateErrorItem[];
101+
}
102+
103+
export interface ProcessErrorItemsParams<Schema extends JsonSchema> {
104+
errorItems: ValidateErrorItem[];
105+
headName: string;
106+
mainSchema: Schema;
107+
}
108+
109+
export type ProcessErrorItemsReturn = {
110+
[ARRAY_AND_OBJECT_ERRORS]: {[key: string]: boolean | string | undefined};
111+
} & {[key: string]: SyncValidateError};
112+
41113
export type GetValidateParams<Schema extends JsonSchema> = {
42114
config: SchemaRendererConfig;
43115
errorMessages?: ErrorMessages;

0 commit comments

Comments
 (0)