tlivings / enjoi

Converts a JSON schema to a Joi schema.
Apache License 2.0
283 stars 57 forks source link

Bug: oneOf type makes field required #61

Closed maldimirov closed 6 years ago

maldimirov commented 6 years ago

Current behavior: The oneOf type makes a field required.

Proper behavior: The oneOf type should make no changes to the required state of the field.

Explanation: The oneOf type is a variation of subschema boolean logic. It's difference to anyOf which works properly in enjoi is that an instance should match exactly one of the subschemas. If it matches two or more - validation fails. But this is only if the instance value is present. That is, if the field is oneOf, but is not included as a required field it should pass validation.