react-jsonschema-form
react-jsonschema-form copied to clipboard
Allow defining custom validation error
Prerequisites
- [X] I have read the documentation
What theme are you using?
core
Is your feature request related to a problem? Please describe.
Currently, when there is a for example Regex pattern in the parameter and the user inputs non-valid content to the input, an error is shown. The developers should be able to modify this error message for a better user experience.
Originally reported to https://github.com/backstage/backstage/issues/22575
Describe the solution you'd like
Allow adding optional validationError to the schema that is shown either by replacing the default error or as an addition to it.
Describe alternatives you've considered
No response
@drodil There is already support for this built into the Form. Take a look at this documentation
Hi, thanks for this. Only problem is that it can only be handled in the Form and not in schema. In backstage there's no access to the rjsf form as a template developer so it's not possible (the templates are only yaml files rendered with rjsf).
I was hoping there was some field in schema to override the default error, but couldn't find anything about that in docs. Is this possible?
@drodil Sorry, there is no support for this in the JSON Schema spec OR ajv... You will have to figure out how to customize backstage to allow you to specify a transformErrors function on the Form, or live with the errors.
Ok, thanks for this @heath-freenome ! I will continue to investigate this on Backstage side