@tsed/ajv 8.14.2-rc.2 → 8.16.0-rc.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/lib/esm/decorators/formats.js +4 -8
- package/lib/esm/decorators/keyword.js +4 -8
- package/lib/esm/fn/formats.js +14 -0
- package/lib/esm/fn/keyword.js +16 -0
- package/lib/esm/index.js +3 -1
- package/lib/types/decorators/formats.d.ts +1 -2
- package/lib/types/decorators/keyword.d.ts +1 -5
- package/lib/types/fn/formats.d.ts +11 -0
- package/lib/types/fn/keyword.d.ts +14 -0
- package/lib/types/index.d.ts +3 -1
- package/lib/types/interfaces/{IAjvSettings.d.ts → AjvSettings.d.ts} +1 -1
- package/lib/types/interfaces/interfaces.d.ts +2 -2
- package/lib/types/services/AjvService.d.ts +1 -1
- package/lib/types/utils/defaultErrorFormatter.d.ts +1 -1
- package/package.json +7 -7
- /package/lib/esm/interfaces/{IAjvSettings.js → AjvSettings.js} +0 -0
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { Injectable } from "@tsed/di";
|
|
1
|
+
import { formats } from "../fn/formats.js";
|
|
3
2
|
/**
|
|
4
3
|
* Create a new custom formats validator
|
|
5
4
|
* @param name
|
|
@@ -8,10 +7,7 @@ import { Injectable } from "@tsed/di";
|
|
|
8
7
|
* @ajv
|
|
9
8
|
*/
|
|
10
9
|
export function Formats(name, options = {}) {
|
|
11
|
-
return
|
|
12
|
-
|
|
13
|
-
}
|
|
14
|
-
name,
|
|
15
|
-
options
|
|
16
|
-
}));
|
|
10
|
+
return (target) => {
|
|
11
|
+
formats(target, name, options);
|
|
12
|
+
};
|
|
17
13
|
}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { Injectable } from "@tsed/di";
|
|
1
|
+
import { keyword } from "../fn/keyword.js";
|
|
3
2
|
/**
|
|
4
3
|
* Create new keyword custom validator
|
|
5
4
|
* @param options
|
|
@@ -7,10 +6,7 @@ import { Injectable } from "@tsed/di";
|
|
|
7
6
|
* @ajv
|
|
8
7
|
*/
|
|
9
8
|
export function Keyword(options) {
|
|
10
|
-
return
|
|
11
|
-
|
|
12
|
-
}
|
|
13
|
-
...options,
|
|
14
|
-
metaSchema: options.metaSchema && options.metaSchema.toJSON ? options.metaSchema.toJSON() : options.metaSchema
|
|
15
|
-
}));
|
|
9
|
+
return (target) => {
|
|
10
|
+
keyword(target, options);
|
|
11
|
+
};
|
|
16
12
|
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { injectable } from "@tsed/di";
|
|
2
|
+
/**
|
|
3
|
+
* Create a new custom formats validator
|
|
4
|
+
* @param token
|
|
5
|
+
* @param name
|
|
6
|
+
* @param options
|
|
7
|
+
* @ajv
|
|
8
|
+
*/
|
|
9
|
+
export function formats(token, name, options = {}) {
|
|
10
|
+
return injectable(token, { type: "ajv:formats" }).set("ajv:formats", {
|
|
11
|
+
name,
|
|
12
|
+
options
|
|
13
|
+
});
|
|
14
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { injectable } from "@tsed/di";
|
|
2
|
+
/**
|
|
3
|
+
* Create a new keyword custom validator
|
|
4
|
+
* @param token
|
|
5
|
+
* @param options
|
|
6
|
+
* @decorator
|
|
7
|
+
* @ajv
|
|
8
|
+
*/
|
|
9
|
+
export function keyword(token, options) {
|
|
10
|
+
return injectable(token)
|
|
11
|
+
.type("ajv:keyword")
|
|
12
|
+
.set("ajv:keyword", {
|
|
13
|
+
...options,
|
|
14
|
+
metaSchema: options.metaSchema && options.metaSchema.toJSON ? options.metaSchema.toJSON() : options.metaSchema
|
|
15
|
+
});
|
|
16
|
+
}
|
package/lib/esm/index.js
CHANGED
|
@@ -4,9 +4,11 @@
|
|
|
4
4
|
export * from "./decorators/formats.js";
|
|
5
5
|
export * from "./decorators/keyword.js";
|
|
6
6
|
export * from "./errors/AjvValidationError.js";
|
|
7
|
+
export * from "./fn/formats.js";
|
|
8
|
+
export * from "./fn/keyword.js";
|
|
7
9
|
export * from "./fn/validate.js";
|
|
10
|
+
export * from "./interfaces/AjvSettings.js";
|
|
8
11
|
export * from "./interfaces/FormatsMethods.js";
|
|
9
|
-
export * from "./interfaces/IAjvSettings.js";
|
|
10
12
|
export * from "./interfaces/interfaces.js";
|
|
11
13
|
export * from "./interfaces/KeywordMethods.js";
|
|
12
14
|
export * from "./services/Ajv.js";
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export type FormatsOptions = Omit<FormatDefinition<any>, "validate" | "compare"> | Omit<AsyncFormatDefinition<any>, "validate" | "compare">;
|
|
1
|
+
import { type FormatsOptions } from "../fn/formats.js";
|
|
3
2
|
/**
|
|
4
3
|
* Create a new custom formats validator
|
|
5
4
|
* @param name
|
|
@@ -1,8 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { AnySchemaObject, KeywordDefinition } from "ajv";
|
|
3
|
-
export type KeywordOptions = Partial<Omit<KeywordDefinition, "metaSchema">> & {
|
|
4
|
-
metaSchema?: AnySchemaObject | JsonSchema;
|
|
5
|
-
};
|
|
1
|
+
import { type KeywordOptions } from "../fn/keyword.js";
|
|
6
2
|
/**
|
|
7
3
|
* Create new keyword custom validator
|
|
8
4
|
* @param options
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { injectable, type TokenProvider } from "@tsed/di";
|
|
2
|
+
import { AsyncFormatDefinition, FormatDefinition } from "ajv";
|
|
3
|
+
export type FormatsOptions = Omit<FormatDefinition<any>, "validate" | "compare"> | Omit<AsyncFormatDefinition<any>, "validate" | "compare">;
|
|
4
|
+
/**
|
|
5
|
+
* Create a new custom formats validator
|
|
6
|
+
* @param token
|
|
7
|
+
* @param name
|
|
8
|
+
* @param options
|
|
9
|
+
* @ajv
|
|
10
|
+
*/
|
|
11
|
+
export declare function formats(token: TokenProvider, name: string, options?: FormatsOptions): ReturnType<typeof injectable>;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { injectable, type TokenProvider } from "@tsed/di";
|
|
2
|
+
import { JsonSchema } from "@tsed/schema";
|
|
3
|
+
import type { AnySchemaObject, KeywordDefinition } from "ajv";
|
|
4
|
+
export type KeywordOptions = Partial<Omit<KeywordDefinition, "metaSchema">> & {
|
|
5
|
+
metaSchema?: AnySchemaObject | JsonSchema;
|
|
6
|
+
};
|
|
7
|
+
/**
|
|
8
|
+
* Create a new keyword custom validator
|
|
9
|
+
* @param token
|
|
10
|
+
* @param options
|
|
11
|
+
* @decorator
|
|
12
|
+
* @ajv
|
|
13
|
+
*/
|
|
14
|
+
export declare function keyword(token: TokenProvider, options: KeywordOptions): ReturnType<typeof injectable>;
|
package/lib/types/index.d.ts
CHANGED
|
@@ -4,9 +4,11 @@
|
|
|
4
4
|
export * from "./decorators/formats.js";
|
|
5
5
|
export * from "./decorators/keyword.js";
|
|
6
6
|
export * from "./errors/AjvValidationError.js";
|
|
7
|
+
export * from "./fn/formats.js";
|
|
8
|
+
export * from "./fn/keyword.js";
|
|
7
9
|
export * from "./fn/validate.js";
|
|
10
|
+
export * from "./interfaces/AjvSettings.js";
|
|
8
11
|
export * from "./interfaces/FormatsMethods.js";
|
|
9
|
-
export * from "./interfaces/IAjvSettings.js";
|
|
10
12
|
export * from "./interfaces/interfaces.js";
|
|
11
13
|
export * from "./interfaces/KeywordMethods.js";
|
|
12
14
|
export * from "./services/Ajv.js";
|
|
@@ -13,7 +13,7 @@ export type ErrorFormatter = (error: AjvErrorObject) => string;
|
|
|
13
13
|
/**
|
|
14
14
|
*
|
|
15
15
|
*/
|
|
16
|
-
export interface
|
|
16
|
+
export interface AjvSettings extends Options {
|
|
17
17
|
Ajv?: any;
|
|
18
18
|
errorFormatter?: ErrorFormatter;
|
|
19
19
|
returnsCoercedValues?: boolean;
|
|
@@ -3,7 +3,7 @@ import { Type } from "@tsed/core";
|
|
|
3
3
|
import { JsonSchema, JsonSchemaObject } from "@tsed/schema";
|
|
4
4
|
import { Ajv, ErrorObject } from "ajv";
|
|
5
5
|
import { AjvValidationError } from "../errors/AjvValidationError.js";
|
|
6
|
-
import { AjvErrorObject, ErrorFormatter } from "../interfaces/
|
|
6
|
+
import { AjvErrorObject, ErrorFormatter } from "../interfaces/AjvSettings.js";
|
|
7
7
|
export interface AjvValidateOptions extends Record<string, any> {
|
|
8
8
|
schema?: JsonSchema | Partial<JsonSchemaObject>;
|
|
9
9
|
type?: Type<any> | any;
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "@tsed/ajv",
|
|
3
3
|
"description": "AJV package for Ts.ED framework",
|
|
4
4
|
"type": "module",
|
|
5
|
-
"version": "8.
|
|
5
|
+
"version": "8.16.0-rc.1",
|
|
6
6
|
"source": "./src/index.ts",
|
|
7
7
|
"main": "./lib/esm/index.js",
|
|
8
8
|
"module": "./lib/esm/index.js",
|
|
@@ -29,12 +29,12 @@
|
|
|
29
29
|
"tslib": "2.7.0"
|
|
30
30
|
},
|
|
31
31
|
"devDependencies": {
|
|
32
|
-
"@tsed/barrels": "8.
|
|
33
|
-
"@tsed/core": "8.
|
|
34
|
-
"@tsed/di": "8.
|
|
35
|
-
"@tsed/exceptions": "8.
|
|
36
|
-
"@tsed/schema": "8.
|
|
37
|
-
"@tsed/typescript": "8.
|
|
32
|
+
"@tsed/barrels": "8.16.0-rc.1",
|
|
33
|
+
"@tsed/core": "8.16.0-rc.1",
|
|
34
|
+
"@tsed/di": "8.16.0-rc.1",
|
|
35
|
+
"@tsed/exceptions": "8.16.0-rc.1",
|
|
36
|
+
"@tsed/schema": "8.16.0-rc.1",
|
|
37
|
+
"@tsed/typescript": "8.16.0-rc.1",
|
|
38
38
|
"ajv": "^8.17.1",
|
|
39
39
|
"eslint": "9.12.0",
|
|
40
40
|
"typescript": "5.4.5",
|
|
File without changes
|