Skip to content

Possible bug: Optional enum string fails validation on empty input #283

@ghost

Description

Description

I do not know if this behaviour is by design or not but when I declare some prop like this one:

const schema = { Status: { type: 'string', uppercase: true, enum: ['a', 'b', 'c'], optional: true, nullable: true } } validate({Status: ''}, schema)

the validation process fails inferring that the empty value '' is not in the stringEnum, even if I've specified the optional and the nullable features. Is this by design? Or shouldn't be the null and empty string, in this case, considered as part of the enumeration or checked before validating the enum? If so it should be documented or at least using optional or nullable with enum should throw an exception...

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions