Skip to content

Blueprint fields with validate can't be left blank #2592

@neildaniels

Description

@neildaniels

Describe the bug
I have a few Blueprint fields with a validate options. I would have expected that empty fields should skip validation (assuming they're not set to required: true). However, empty fields still seem to go through a validation check.

To Reproduce
Steps to reproduce the behavior:

  1. Add a field to a page blueprint, such as:
      someId:
        label: Some ID
        type: text
        validate:
          integer
        translate: false

or

      someCode:
        label: Some Code
        type: text
        minlength: 2
        maxlength: 2
        validate:
          alpha
        translate: false
  1. Leave these field blank, but make a change to some other field (to force the Save bar to appear).
  2. Try to save the page in the Panel.
  3. Get error saying you need to "enter a valid integer" or "only enter characters between a-z".

Expected behavior
If a field is left empty, then validation should be skipped.

Kirby Version
3.3.5

Desktop (please complete the following information):

  • OS: macOS
  • Browser: Safari
  • Version: 13.1 (15609.1.20.111.8)

Additional context
According to @texnixe, in February:

A field is only validated with a validator if it has input. To enforce input, you have to require it, because otherwise it can be left empty.

It seems like genuinely empty fields (and not required) should skip validation.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions