Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: align how IBAN validators messages work with other validators #2239

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

ryubro
Copy link
Contributor

@ryubro ryubro commented Apr 1, 2024

What I did

  1. Aligned the way how the messages of IBAN validator is loaded with other validators
    • While many other validators override getMessage() class method by calling separate functions, IBAN validators override getMessage() instance method which loads its own translation messages
      • As the result, current IBAN validators show default messages without calling loadDefaultFeedbackMessages() while many other validators show the fallback messages like:

        Please configure an error message for "xxx" by overriding "static async getMessage()"

      • By aligning IBAN validators with others, now IBAN validators don't show default messages without calling loadDefaultFeedbackMessages() or loadInputIBANMessagesNoSideEffects() which is a BREAKING CHANGE
  2. [boy-scouting] Add missed loadDefaultFeedbackMessages() to input-email document

Why

While checking an old issue about IBAN error message (#1783), I found we can override the error message by doing:

IsIBAN.getMessage = () => 'Vul een geldige Rekeningnummer in.';

html`
  <lion-input-iban .modelValue=${'NL20INGB0001234567XXXX'}></lion-input-iban>
`;

but this requires the consumer of the component to know the implementation details that IsIBAN is the default validator of lion-input-iban.

If consumers see the message like Please configure an error message for "IsIBAN" by overriding "static async getMessage()", it is easier to figure out what needs to be done.

Also this behavior is more consistent with how other validators work and its document: https://lion-web.netlify.app/components/input-iban/use-cases/#country-restrictions

To get the default feedback message for this default validator, use loadDefaultFeedbackMessages from @lion/form-core.

Discussion

  • Even with the given benefits, whether they are worth the breaking change is a separate issue
  • Is this technically a breaking change, while the new behavior is conforming to the existing document?

Copy link

changeset-bot bot commented Apr 1, 2024

⚠️ No Changeset found

Latest commit: 4c02297

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@CLAassistant
Copy link

CLAassistant commented Apr 1, 2024

CLA assistant check
All committers have signed the CLA.

@ryubro ryubro force-pushed the fix/load-iban-translations-separately branch from 74de31b to 4c02297 Compare April 2, 2024 01:04
@ryubro ryubro changed the title Fix/load iban translations separately chore: align how IBAN validators is loaded with other validators Apr 2, 2024
@ryubro ryubro changed the title chore: align how IBAN validators is loaded with other validators chore: align how IBAN validators messages work with other validators Apr 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants