@fastify/ajv-compiler
Advanced tools
Comparing version 3.2.0 to 3.3.0
@@ -32,5 +32,5 @@ import { default as _ajv, Options } from "ajv"; | ||
export type { Options } from "ajv"; | ||
export type { Options, ErrorObject } from "ajv"; | ||
export type Ajv = _ajv; | ||
export default ValidatorSelector; | ||
export { StandaloneValidator }; | ||
export { StandaloneValidator }; |
@@ -51,2 +51,3 @@ 'use strict' | ||
} else { | ||
console.log(Object.assign({}, defaultAjvOptions, options.customOptions)) | ||
this.ajv = new Ajv(Object.assign({}, defaultAjvOptions, options.customOptions)) | ||
@@ -89,2 +90,4 @@ } | ||
console.log({ schema }) | ||
return this.ajv.compile(schema) | ||
@@ -91,0 +94,0 @@ } |
{ | ||
"name": "@fastify/ajv-compiler", | ||
"version": "3.2.0", | ||
"version": "3.3.0", | ||
"description": "Build and manage the AJV instances for the fastify framework", | ||
@@ -47,6 +47,6 @@ "main": "index.js", | ||
"tap": "^16.2.0", | ||
"tsd": "^0.22.0" | ||
"tsd": "^0.23.0" | ||
}, | ||
"dependencies": { | ||
"ajv": "^8.10.0", | ||
"ajv": "^8.11.0", | ||
"ajv-formats": "^2.1.1", | ||
@@ -53,0 +53,0 @@ "fast-uri": "^2.0.0" |
@@ -277,1 +277,35 @@ 'use strict' | ||
}) | ||
t.test('global refs in main schemas', (t) => { | ||
t.plan(2) | ||
const factory = AjvCompiler() | ||
const compiler = factory({}, { | ||
customOptions: { | ||
addUsedSchema: false | ||
} | ||
}) | ||
const validatorFunc1 = compiler({ | ||
schema: { | ||
definitions: { | ||
globalIdSchema: { | ||
$id: 'globalId', | ||
type: 'integer' | ||
} | ||
}, | ||
$ref: 'globalId' | ||
} | ||
}) | ||
const validatorFunc2 = compiler({ | ||
schema: { | ||
definitions: { | ||
globalIdSchema: { | ||
$id: 'globalId', | ||
type: 'string' | ||
} | ||
}, | ||
$ref: 'globalId' | ||
} | ||
}) | ||
t.equal(validatorFunc1(3), true) | ||
t.equal(validatorFunc2(3), false) | ||
}) |
@@ -0,3 +1,4 @@ | ||
import { AnySchemaObject } from "ajv"; | ||
import { expectAssignable, expectType } from "tsd"; | ||
import ValidatorSelector, { ValidatorCompiler, StandaloneValidator, RouteDefinition } from "../.."; | ||
import ValidatorSelector, { ValidatorCompiler, StandaloneValidator, RouteDefinition, ErrorObject } from "../.."; | ||
@@ -23,1 +24,11 @@ const compiler = ValidatorSelector(); | ||
expectType<ValidatorCompiler>(writer); | ||
expectType<unknown>(({} as ErrorObject).data) | ||
expectType<string>(({} as ErrorObject).instancePath) | ||
expectType<string>(({} as ErrorObject).keyword) | ||
expectType<string | undefined>(({} as ErrorObject).message) | ||
expectType<Record<string, any>>(({} as ErrorObject).params) | ||
expectType<AnySchemaObject | undefined>(({} as ErrorObject).parentSchema) | ||
expectType<string | undefined>(({} as ErrorObject).propertyName) | ||
expectType<unknown>(({} as ErrorObject).schema) | ||
expectType<string>(({} as ErrorObject).schemaPath) |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
37233
18
924
Updatedajv@^8.11.0