Skip to content

Better Validation Error Messages for Front-End #1409

@Dinesht04

Description

@Dinesht04

Is your enhancement request related to a problem?

No, not a problem. But I think it is a required enhancement.
When the validation of an input fails in the back-end. The error message includes the 'key' of the value.
For Eg: For Minimum Question Body Length, the error message includes "min_content"
Many other examples in the picture linked below

Image

Describe the solution you'd like

I checked into this and validator library sends the message directly.
Since the key_name is necessary for debugging in back-end, maybe we can add a utility function in the front-end where it replaces the key of the value with the label for the field.

The draft vision for the function that I have right now is :-
The first word for every error message contains the key name. So we extract the first word, small case the first letter, then match it for it's label in the translations files.

Describe alternatives you've considered

An easier approach would be to just remove the first word from the error message since the placement of the error message gives enough context about which field is failing the validation and the keys that we are rendering right now might as well be redundant.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions