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

Highlighting single date fields which are in error #455

Open
DavidBiddle opened this issue Dec 7, 2023 · 3 comments
Open

Highlighting single date fields which are in error #455

DavidBiddle opened this issue Dec 7, 2023 · 3 comments
Labels
enhancement New feature or request

Comments

@DavidBiddle
Copy link

The Design System's guidance for Date Inputs has a subsection about error messages. This contains the following recommendations (abridged slightly):

If you’re highlighting just one field - either the day, month or year - only style the field that has an error. The error message must say which field has an error

If nothing is entered: Highlight the date input as a whole.
If the date is incomplete: Highlight the day, month or year field where the information is missing or incomplete. If more than one field is missing information, highlight the fields the user needs to fill in.
If the date entered cannot be correct: For example, ‘13’ in the month field cannot be correct. Highlight the day, month or year field with the incorrect information. Or highlight the date as a whole if there’s incorrect information in more than one field, or it’s not clear which field is incorrect.
If the date is in the future when it needs to be in the past: Highlight the date input as a whole.
If the date is in the future when it needs to be today or in the past: Highlight the date input as a whole.
If the date is in the past when it needs to be in the future: Highlight the date input as a whole.
If the date is in the past when it needs to be today or in the future: Highlight the date input as a whole.
If the date must be the same as or after another date: Highlight the date input as a whole.
If the date must be after another date: Highlight the date input as a whole.
If the date must be the same as or before another date: Highlight the date input as a whole.
If the date must be before another date: Highlight the date input as a whole.
If the date must be between two dates: Highlight the date input as a whole.

Is there a known/recommended way to highlight a single date field that's in error? As far as I can tell there's no easy way of doing this with the gem's date input component.

@peteryates
Copy link
Member

There isn't because the field is bound to a date object which as far as Ruby is concerned is either valid or invalid.

I've been thinking about the best way of checking it, as have others, but taking on the role of actually validating the dates goes beyond the scope of this library.

It might be the case that the builder will display a certain format of errors but the building of them is the responsibility of the app - or via a separate gem.

I'm definitely open to collaborating on a nice, reusable solution for this. cc @felixclack

@peteryates peteryates added the enhancement New feature or request label Dec 9, 2023
@peteryates
Copy link
Member

Began experimenting with ways to address this in #462.

@peteryates
Copy link
Member

Some work has been done on this front:

Now it's possible to fully customise the errors. Here's LAA-submit-crime-forms:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants