vovk-ajv 0.0.0-draft.71 → 0.0.0-draft.72
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/index.js +3 -2
- package/package.json +2 -2
package/index.js
CHANGED
|
@@ -18,6 +18,7 @@ const createAjv = (options, target) => {
|
|
|
18
18
|
(0, ajv_errors_1.default)(ajv);
|
|
19
19
|
ajv.addKeyword('x-isDto');
|
|
20
20
|
ajv.addKeyword('x-formData');
|
|
21
|
+
ajv.addKeyword('x-tsType');
|
|
21
22
|
return ajv;
|
|
22
23
|
};
|
|
23
24
|
const validate = ({ data, schema, ajv, localize = 'en', type, endpoint, }) => {
|
|
@@ -29,7 +30,7 @@ const validate = ({ data, schema, ajv, localize = 'en', type, endpoint, }) => {
|
|
|
29
30
|
const isValid = ajv.validate(schema, data);
|
|
30
31
|
if (!isValid) {
|
|
31
32
|
ajv_i18n_1.default[localize](ajv.errors);
|
|
32
|
-
throw new vovk_1.HttpException(vovk_1.HttpStatus.NULL, `Ajv validation failed. Invalid ${isForm ? 'form' : type} on client: ${ajv.errorsText()}`,
|
|
33
|
+
throw new vovk_1.HttpException(vovk_1.HttpStatus.NULL, `Ajv validation failed. Invalid ${isForm ? 'form' : type} on client: ${ajv.errorsText()}`, { data, errors: ajv.errors, endpoint });
|
|
33
34
|
}
|
|
34
35
|
}
|
|
35
36
|
};
|
|
@@ -39,7 +40,7 @@ const validateAll = ({ input, validation, ajv, localize = 'en', }) => {
|
|
|
39
40
|
validate({ data: input.params, schema: validation.params, ajv, localize, endpoint: input.endpoint, type: 'params' });
|
|
40
41
|
};
|
|
41
42
|
const getConfig = (schema) => {
|
|
42
|
-
const config = schema.meta
|
|
43
|
+
const config = schema.meta?.config?.libs?.ajv;
|
|
43
44
|
const options = config?.options ?? {};
|
|
44
45
|
const localize = config?.localize ?? 'en';
|
|
45
46
|
const target = config?.target ?? 'draft-2020-12';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "vovk-ajv",
|
|
3
|
-
"version": "0.0.0-draft.
|
|
3
|
+
"version": "0.0.0-draft.72",
|
|
4
4
|
"description": "Local validation for JSON schemas for vovk-zod and other validation libraries for Vovk.ts",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -33,6 +33,6 @@
|
|
|
33
33
|
"ajv-i18n": "^4.2.0"
|
|
34
34
|
},
|
|
35
35
|
"peerDependencies": {
|
|
36
|
-
"vovk": "^3.0.0-draft.
|
|
36
|
+
"vovk": "^3.0.0-draft.297"
|
|
37
37
|
}
|
|
38
38
|
}
|