JSON validation
M.ajvMetadata and JSON schema
M.ajvMetadata and JSON schemaimport Ajv from 'ajv'
const ajvOptions = {}
const ajvIfProd = (ENV === 'development') ? Ajv(ajvOptions) : undefined
const {string, list, number} = M.ajvMetadata(ajvIfProd)
class Animal extends M.Base {
static innerTypes() {
return Object.freeze({
name: string({minLength: 1, maxLength: 25}),
dimensions: list(
number({exclusiveMinimum: 0}),
{minItems: 3, maxItems: 3}
)
})
}
}Custom validation metadata
Why not both?
Overriding the reviver
Last updated