[BLOSSOM-288] Validator is always executed Created: 17/Jan/22  Updated: 24/Mar/22  Resolved: 17/Feb/22

Status: Closed
Project: Blossom
Component/s: None
Affects Version/s: 3.4.7
Fix Version/s: 3.5.0

Type: Bug Priority: Neutral
Reporter: Carlos Cantalapiedra Assignee: Javier Benito
Resolution: Fixed Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: 3h
Original Estimate: Not Specified

Issue Links:
Problem/Incident
Relates
relates to BLOSSOM-290 Enable UI 6 definition usage in dialo... Closed
Template:
Acceptance criteria:
Empty
Task DoD:
[X]* Doc/release notes changes? Comment present?
[X]* Downstream builds green?
[X]* Solution information and context easily available?
[X]* Tests
[X]* FixVersion filled and not yet released
[ ]  Architecture Decision Record (ADR)
Bug DoR:
[X]* Steps to reproduce, expected, and actual results filled
[X]* Affected version filled
Date of First Response:
Sprint: DevX 4
Story Points: 5

 Description   

Steps to reproduce

  1.  Create a component in Blossom (e.g, a textField)
  2.  Set a validator:
    cfg.fields.text("cityId")
      .validator(cfg.validators.digitsOnly()
      .errorMessage("Only numbers"))
      .label("City Id")
      .description("Insert the Id of the city")
  1.  Check that when setting the validator, old info.magnolia.ui.form.validator.definition.RegexpValidatorDefinition class is instantiated instead of info.magnolia.ui.field.RegexpValidatorDefinition
  2.  Don't fulfill any value at the previous field (cityId)
  3.  Try to save the dialog
  4.  Check the validator is triggered tho no value has been typed

Expected results

Validator is executed only if the field has data

Actual results

Validator is always executed

Workaround

Switch to new M6UI info.magnolia.ui.field.RegexpValidatorDefinition class

Development notes

This is not directly a Blossom issue, same behavior happens for any field regardless the definition process. E.g, go to our demo and edit the TextAndImage component. At the headline section include the following validator (old class):

- name: headline
  class: info.magnolia.ui.form.field.definition.TextFieldDefinition
  i18n: true
  validators:
    - name: digitsOnly
      class: info.magnolia.ui.form.validator.definition.RegexpValidatorDefinition
      pattern: ^\d{5}(-\d{4})?$
      errorMessage: Please, enter a number

Now go to Pages app, create a new page and on the main area, create a TextAndImage component. Try to save it without inputing any value and check the validator is executed.

Perform the same test at the mtk2 with the new regexValidator class:

validators:
  numberValidator:
    $type: regexpValidator
    pattern: ^[+]*[0-9\s]*
    errorMessage: Please enter a number

Check that if you try to save the dialog when no data has been included at the headline field, the dialog gets saved properly.



 Comments   
Comment by Mikaël Geljić [ 16/Feb/22 ]

rephrasing as this was in fact an independent issue from the fact that blossom still uses old validator packages.

Generated at Sun Feb 11 23:32:00 CET 2024 using Jira 9.4.2#940002-sha1:46d1a51de284217efdcb32434eab47a99af2938b.