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

Add error messages to field constraint samples #3548

Open
rolfsmeds opened this issue Jul 19, 2024 · 3 comments
Open

Add error messages to field constraint samples #3548

rolfsmeds opened this issue Jul 19, 2024 · 3 comments
Assignees

Comments

@rolfsmeds
Copy link
Contributor

rolfsmeds commented Jul 19, 2024

Once the error message API has been merged, make sure that the samples with constraints for each field have appropriate error messages for each constraint:

  • Checkbox (required)
  • ComboBox (required)
  • DatePicker (could the min/max sample be simplified with the new mechanism?)
  • EmailField (required, pattern)
  • NumberField (min/max, step)
  • PasswordField (required, min/max)
  • TextArea (required, min/max, pattern)
  • TextField (required, min/max, pattern)
  • TimePicker (could the min/max sample be simplified with the new mechanism?)

Part of vaadin/flow-components#4618

@vursen
Copy link
Contributor

vursen commented Jul 31, 2024

I have a proposal:

How about we add a "Constraints" section to the DatePicker and TimePicker articles, replacing their min/max examples, to align these articles with text fields? In this section, we would also include the required constraint, which is currently missing. Then, we could also add this section to other fields like Select, ComboBox, etc, as they also have one constraint: required.

I'm not sure if using i18n for error messages is necessary for single-constraint components. Maybe we could use setErrorMessage() in their examples, or we could still use i18n for consistency.

@rolfsmeds
Copy link
Contributor Author

I suppose we could do something like that, but let's keep the Custom Validation sections separate like now.
As for ComboBox, it already has a Constraints section. I think the fields that only have required are Select, Checkbox and RadioButtonGroup, but it feels a bit silly to add a Constraints section just for that. And since you can use setErrorMessage for that anyway, maybe it doesn't need to be explicitly documented?

@vursen
Copy link
Contributor

vursen commented Sep 2, 2024

Meeting notes from our internal session on August 26, 2024:

  • Add brief description of what constraints are etc as a leading paragraph in the Constraints sections.
  • Link from there to Flow and Hilla Data Binding and Validation docs pages. (E.g. from an admonition or from the leading paragraph.)
  • Add "Bad Input" to constraint section.
  • Let's stick to non-Binder samples on component pages, with the possible exception of samples where it doesn't make much sense to demo without Binder.
  • Rename "Constraints" sections to "Validation"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants