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

ValidatedTextInput: automatically default label to the label in the field's yup schema #69

Open
mturley opened this issue Jul 1, 2021 · 0 comments

Comments

@mturley
Copy link
Collaborator

mturley commented Jul 1, 2021

Currently, to get nice-looking validation errors we have to repeat all our field labels in two places: in the schema and on the form field itself.

Looking at the TS types for yup, we should be able to grab the label set in the schema's label() method by looking at schema.spec.label: https://github.com/jquense/yup/blob/master/src/schema.ts#L42

We can probably use this in ValidatedTextInput to automatically provide a default for the label prop so it will render the schema's label if the consumer doesn't pass one in.

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

No branches or pull requests

1 participant