Skip to content

Question: how to specify a property that is an enum but could also be null #1036

@ecarey-paa

Description

@ecarey-paa

how does one specify an enum prop that could also be null? the following does not work:

schema = {
    "type": "object",
    "properties": {
        "foo": {
            "enum": ["abc", "xyz", "null"]
        }
    }
}
validate({"foo":None},schema)

interestingly the following does?

schema = {
    "foo": {
        "enum": ["abc", "xyz", "null"]
    }
}
validate({"foo":None},schema)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions