typewriter
typewriter copied to clipboard
In development Mode ajv.validate causes Error: unknown format "date-time"
I am seeing an issue in the generated segment.ts in which I receive an error
Error: unknown format "date-time" ignored in schema at path "#/properties/...."
My fix right now is to do
import addFormats from 'ajv-formats'
Then change the generated method to
function validateAgainstSchema(message: Record<string, any>, schema: object) {
const ajv = new Ajv({ allErrors: true, verbose: true })
//@ts-ignore
addFormats(ajv)
if (!ajv.validate(schema, message) && ajv.errors) {
onViolation(message, ajv.errors)
}
}
This is obviously not ideal because this is a generated file that shouldn't be edited.
Is there a recommended solution to this?
I'm using these package versions:
"ajv": "^8.12.0",
"ajv-formats": "2.1.1",
"typewriter": "9.0.0",