Objection.js: Patch validation fail with one of required fields

Created on 6 Dec 2017  路  6Comments  路  Source: Vincit/objection.js

Hi,

giving the following model JSON schema:

{
   "oneOf": [
      { "required": ["email"] },
      { "required": ["username"] }
   ],
   "properties": {
      "email": { "type": "string" },
      "password": { "type": "string" },
      "username": { "type": "string" }
   },
   "type": "object"
}

If we want to PATCH one instance of this model only with the password field, we have a validation error because one of the fields (email or username) is required. Patch operations ignores the required fields. Shouldn't the oneOf required fields be ignored as well?

Thank you!

enhancement

Most helpful comment

Ok. Thanks for bringing this up. I'll get this fixed in the next patch version.

All 6 comments

Ha, I didn't know required could be set like that. Are you sure that's a supported syntax? If it is then yes, those should be ignored as well

This syntax is supported (example in ajv documentation https://github.com/epoberezkin/ajv#filtering-data)

Ok. Thanks for bringing this up. I'll get this fixed in the next patch version.

@koskimas, any plans for releasing 0.9.3 ?

@joaonice I released 0.9.3 today

@koskimas thanks!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

apronin83 picture apronin83  路  3Comments

bsdo64 picture bsdo64  路  3Comments

ghost picture ghost  路  3Comments

mycahjay-nms picture mycahjay-nms  路  4Comments

Ahlid picture Ahlid  路  3Comments