[@feathersjs/schema] Schema cannot handle validating properties with date formats
See original GitHub issueSteps to reproduce
Schemas using the format
attribute, such as date-time
are not validating correctly with @feathersjs/schema. I am specifically trying to validate ISO string timestamps from PostgreSQL.
The error looks something like this, depending on your schema property’s name:
Error: unknown format "date-time" ignored in schema at path "#/properties/createdAt"
See the below Code Sandbox, it validates the schema fine with standalone AJV, but not with @feathersjs/schema. Just comment back in Line 44 to reproduce the error.
https://codesandbox.io/s/ajv-playground-forked-owbvqe?file=/src/index.js
Expected behavior
Date formats should be recognized by Feathers when validating a schema.
Actual behavior
The console throws this error:
Error: unknown format "date-time" ignored in schema at path "#/properties/<your-field-name>"
System configuration
Tell us about the applicable parts of your setup.
Module versions (especially the part that’s not working): Feathers packages:
"@feathersjs/authentication": "^4.5.11",
"@feathersjs/authentication-local": "^4.5.15",
"@feathersjs/authentication-oauth": "^4.5.15",
"@feathersjs/configuration": "^4.5.15",
"@feathersjs/errors": "^4.5.11",
"@feathersjs/express": "^4.5.11",
"@feathersjs/feathers": "^4.5.11",
"@feathersjs/schema": "^5.0.0-pre.23",
"@feathersjs/socketio": "^4.5.15",
"@feathersjs/transport-commons": "^4.5.11",
And AJV packages:
"ajv": "^8.11.0",
"ajv-errors": "^3.0.0",
"ajv-formats": "^2.1.1",
NodeJS version: v17.0.0
Operating System: MacOS v12.2.1
Issue Analytics
- State:
- Created a year ago
- Comments:10
Top GitHub Comments
Off-topic: I also suggest ajv-errors, you can do nice things then
You’re correct, defining it as
type: 'object'
also works. That is probably a better option for the sake of simplicity.Since that works, I’m going to go ahead and close this issue. Thanks @edgar-koster !