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

docs: explain constraint validation, add error messages #3640

Open
wants to merge 24 commits into
base: latest
Choose a base branch
from

Conversation

vursen
Copy link
Contributor

@vursen vursen commented Sep 4, 2024

Explains constraint validation and updates the examples to use new i18n error messages for:

  • DatePicker
  • TextField
  • EmailField

Part of #3548

@github-actions github-actions bot added the Language unchecked English language check has not been done label Sep 4, 2024
@vursen vursen changed the title docs: explain text field validation docs: explain TextField validation, add error messages Sep 4, 2024
@vursen vursen changed the title docs: explain TextField validation, add error messages docs: explain constraint validation, add error messages Sep 4, 2024
@@ -193,10 +193,16 @@ The pattern is a regular expression used to validate the full value entered into
[%collapsible]
====
A separate single-character, regular expression can be used to restrict the characters that can be entered into the field. Characters that don't match the expression are rejected.

However, programmatically set values are not subject to this restriction, even if they contain disallowed characters. To validate these values, a pattern constraint should be used additionally.
Copy link
Contributor Author

@vursen vursen Sep 12, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wanted to add this note but I've realized there is a complication. ComboBox and MultiSelectComboBox both have setAllowedCharPattern, but they don't have setPattern or if they do, it doesn't work, see vaadin/flow-components#6635.

I'm now not sure. I wonder whether there is actually a use-case for setAllowedCharPattern for MultiSelectComboBox. At first glance, the required constraint seems to be the only reasonable.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess you could have a CB where you should only be able to enter numbers or something. In any case, both pattern and allowChars are really only meaningful for custom entry. I'd mention it as planned for now and see if we can fix 6635.

@vursen vursen marked this pull request as ready for review September 12, 2024 10:47
@@ -144,7 +144,7 @@ Disabled fields can be useful in situations where they can become enabled based


////
CONSTRAINT FEATURES
VALIDATION FEATURES
////

// tag::constraints-intro[]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can't comment an unchanged line, but shouldn't the heading below also say Validation?

articles/components/_input-field-common-features.adoc Outdated Show resolved Hide resolved
@@ -193,10 +193,16 @@ The pattern is a regular expression used to validate the full value entered into
[%collapsible]
====
A separate single-character, regular expression can be used to restrict the characters that can be entered into the field. Characters that don't match the expression are rejected.

However, programmatically set values are not subject to this restriction, even if they contain disallowed characters. To validate these values, a pattern constraint should be used additionally.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess you could have a CB where you should only be able to enter numbers or something. In any case, both pattern and allowChars are really only meaningful for custom entry. I'd mention it as planned for now and see if we can fix 6635.

articles/components/_input-field-common-features.adoc Outdated Show resolved Hide resolved
articles/components/date-picker/index.adoc Outdated Show resolved Hide resolved
articles/components/date-picker/index.adoc Outdated Show resolved Hide resolved
articles/components/email-field/index.adoc Outdated Show resolved Hide resolved
articles/components/text-field/index.adoc Outdated Show resolved Hide resolved
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Language unchecked English language check has not been done
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants