Skip to content

Should enum really include null? #258

@Relequestual

Description

@Relequestual

The specification says that enum may include null.
If type does not also include null, although the validation check for the enum key word will pass, the validation check for the type key word will mean the instance fails overall validation. The inverse is also true.

Usecase:
I have a value which may be a number of strings, or null.
Valid values are "a", "b", or NULL.
To define and pass validation:
I must set the type to ["string", "null"]
AND
I must set enum to ["a", "b", null]

If we want to keep this behaviour, as we are commenting that enum may be null, we should point out that when doing so, if you expect validation to pass for an instance where you define the type, you must also include null in the type.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions