[MGNLFORM-398] Custom Validators cannot be used within the edit form dialog Created: 16/Jan/24  Updated: 17/Jan/24

Status: Open
Project: Magnolia Form Module
Component/s: None
Affects Version/s: 2.7.8
Fix Version/s: None

Type: Bug Priority: Neutral
Reporter: Carlos Cantalapiedra Assignee: Unassigned
Resolution: Unresolved Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Attachments: Java Source File UniquePhoneNumberValidator.java     Java Source File UniquePhoneNumberValidatorDefinition.java     Java Source File UniquePhoneNumberValidatorFactory.java     XML File config.modules.form.dialogs.formStep.form.tabs.tabMain.fields.formName.validators.xml    
Issue Links:
Problem/Incident
Template:
Acceptance criteria:
Empty
Task DoD:
[ ]* Doc/release notes changes? Comment present?
[ ]* Downstream builds green?
[ ]* Solution information and context easily available?
[ ]* Tests
[ ]* FixVersion filled and not yet released
[ ]  Architecture Decision Record (ADR)
Bug DoR:
[ ]* Steps to reproduce, expected, and actual results filled
[ ]* Affected version filled
Team: AuthorX

 Description   

Steps to reproduce

  1.  Create a java module with the provided Validator
  2.  Open Configuration app and move to /modules/form/dialogs/formStep/form/tabs/tabMain/fields/formName
  3. Select the formName node and import the attached xml
  4. Go to Resources app and edit /mtk2/templates/pages/basic.yaml
  5. Include the following component within the main area:
    mtk2/templates/pages/basic.yaml
    form:
      id: form:components/form
  6. Open pages app and create a Basic page
  7. Within the main area, create a Form component
  8. Type something within the Form name field
  9. Check nothing is printed at console (Validator should have printed "Custom unique phone number validation executed")
  10. Go to Definitions app and check a minor error is displayed within the Problems tab:

    Definition: form:formStep
    Origin: /modules/form/dialogs/formStep
    Details: Element [my.company.filter.UniquePhoneNumberValidatorDefinition@280e405f] of type [my.company.filter.UniquePhoneNumberValidatorDefinition] may not be added to the collection of type [interface info.magnolia.ui.form.validator.definition.FieldValidatorDefinition]
    Location: /form/tabs/tabMain/fields/formName/validators/uniquePhone
    Type: Source data processing problem
    Severity: MINOR

Expected results

The custom field validator works

Actual results

Validator cannot be used within the form module (form component)

Workaround

N/A

Development notes

The very same validator works if defined as a field validator at other components (e.g, at a TextField component)

If we switch the Validator definition to the old UI, we still get an error:

WARN class my.company.filter.UniquePhoneNumberValidatorDefinition$ByteBuddy$LBqhP0eh doesn't have replacement in new ui framework. So it can't be converted and as such is skipped.

 


Generated at Mon Feb 12 05:39:48 CET 2024 using Jira 9.4.2#940002-sha1:46d1a51de284217efdcb32434eab47a99af2938b.