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

Allow defining custom validation error #4077

Open
1 task done
drodil opened this issue Feb 3, 2024 · 4 comments
Open
1 task done

Allow defining custom validation error #4077

drodil opened this issue Feb 3, 2024 · 4 comments

Comments

@drodil
Copy link

drodil commented Feb 3, 2024

Prerequisites

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 backstage/backstage#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 drodil added feature Is a feature request needs triage Initial label given, to be assigned correct labels and assigned labels Feb 3, 2024
@heath-freenome heath-freenome added question awaiting response possibly close To confirm if this issue can be closed and removed needs triage Initial label given, to be assigned correct labels and assigned feature Is a feature request labels Feb 16, 2024
@stale stale bot removed the possibly close To confirm if this issue can be closed label Feb 16, 2024
@heath-freenome
Copy link
Member

@drodil There is already support for this built into the Form. Take a look at this documentation

@drodil
Copy link
Author

drodil commented Feb 16, 2024

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?

@heath-freenome
Copy link
Member

@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.

@drodil
Copy link
Author

drodil commented Feb 22, 2024

Ok, thanks for this @heath-freenome ! I will continue to investigate this on Backstage side

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