Skip to content

Commit 4dba8c3

Browse files
committed
test(unstable): add service field utils tests
1 parent 2e663bd commit 4dba8c3

17 files changed

+7440
-564
lines changed
Lines changed: 2 additions & 110 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,6 @@
1-
import type {ErrorObject, ValidateFunction} from 'ajv';
2-
import type {FieldValidator} from 'final-form';
1+
import type {ErrorObject} from 'ajv';
32

4-
import type {ARRAY_AND_OBJECT_ERRORS} from '../constants';
5-
import type {
6-
ErrorsState,
7-
SetValidationCacheMutator,
8-
SetValidationWaitersMutator,
9-
ValidationState,
10-
ValidationWaiter,
11-
} from '../mutators';
12-
import type {
13-
AsyncValidateError,
14-
ErrorMessages,
15-
FieldValue,
16-
JsonSchema,
17-
ObjectValue,
18-
SchemaRendererConfig,
19-
SchemaToValueType,
20-
SyncValidateError,
21-
Validator,
22-
} from '../types';
3+
import type {FieldValue, JsonSchema, SyncValidateError, Validator} from '../types';
234

245
export type EntityParametersError = ErrorObject<
256
'entityParameters',
@@ -30,96 +11,7 @@ export type EntityParametersError = ErrorObject<
3011
}
3112
>;
3213

33-
export type GetAjvValidateParams = {
34-
config: SchemaRendererConfig;
35-
mainSchema: JsonSchema;
36-
};
37-
38-
export interface GetAjvValidateReturn extends ValidateFunction {
39-
errors?: (ErrorObject | EntityParametersError)[];
40-
}
41-
42-
export interface GetAjvErrorMessageParams {
43-
ajvErrorMessage?: string;
44-
errorMessages: ErrorMessages | undefined;
45-
instancePath: string;
46-
keyword: string;
47-
mainSchema: JsonSchema;
48-
schemaPath: string;
49-
}
50-
5114
export interface ValidateErrorItem {
5215
error: SyncValidateError;
5316
path: string[];
5417
}
55-
56-
export interface ProcessEntityParametersErrorParams {
57-
allValues: ObjectValue;
58-
error: EntityParametersError;
59-
headName: string;
60-
onAsyncError: (waiter: {
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 | undefined;
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-
113-
export type GetValidateParams<Schema extends JsonSchema> = {
114-
config: SchemaRendererConfig;
115-
errorMessages?: ErrorMessages;
116-
headName: string;
117-
mainSchema: Schema;
118-
serviceFieldName: string;
119-
setValidationCache: SetValidationCacheMutator;
120-
setValidationWaiters: SetValidationWaitersMutator;
121-
};
122-
123-
export type GetValidateReturn<Schema extends JsonSchema> = FieldValidator<
124-
SchemaToValueType<Schema>
125-
>;

0 commit comments

Comments
 (0)