Skip to content

Format validation does not work well with optional fields #930

@jamesleeht

Description

@jamesleeht

The format tag does not work with required: true on strings.

Notably, if you use format:email and the email field is optional, the validation will fail since an empty string does not pass the format check.

One workaround I've found is to use the pattern tag instead where you can set a regex which also lets empty strings through.

Is there a better way around this?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions