question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[@feathersjs/schema] Schema cannot handle validating properties with date formats

See original GitHub issue

Steps 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:closed
  • Created a year ago
  • Comments:10

github_iconTop GitHub Comments

1reaction
edgar-kostercommented, Jul 6, 2022

Off-topic: I also suggest ajv-errors, you can do nice things then

0reactions
ejmudrakcommented, Jul 7, 2022

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 !

Read more comments on GitHub >

github_iconTop Results From Across the Web

Validators - Feathers.js
The following hooks take a validation function and validate parts of the hook context. validateData #. schemaHooks.validateData takes a ...
Read more >
feathers-schema - npm
Start using feathers-schema in your project by running `npm i feathers-schema`. ... of attributes that apply to it, and cannot validate nested properties....
Read more >
How can I validate Date format in FeatherJS - Stack Overflow
Try to use Moment JS to validate the Date you can also use this to format dates , Set Timezone etc. https://momentjs.com/.
Read more >
MessagePack: It's like JSON. but fast and small.
MessagePack is an efficient binary serialization format. It lets you exchange data among multiple languages like JSON. But it's faster and smaller.
Read more >
HTML Standard
The DOM, the HTML syntax, and the XML syntax cannot all represent the same ... The WHATWG maintains a list of such tools...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found