-
Notifications
You must be signed in to change notification settings - Fork 81
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
feat(Validation): Add new Validation components #351
Conversation
- add ValidationChecklist, ValidationItem - add validation prop to Alert
<ValidationChecklist id="validate-password"> | ||
<ValidationItem | ||
id="required" | ||
isValid={values.password.length > 0}> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ideally isValid
would use different logic than this - just did something simple for the example. Open to other ways to do this. The alternative I found was writing a long validate
function that digs inside yup
's error object and manually updated bits of component state. It seemed like overkill for this example.
react hook form seems to handle this better than formik... couldn't find a similar formik util.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ahh I see, yeah I wouldn't worry too much about this since it's really a Formik implementation detail..
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I really like the implementation of these components, and I love how thorough the examples and tests are! 🚀
<ValidationChecklist id="validate-password"> | ||
<ValidationItem | ||
id="required" | ||
isValid={values.password.length > 0}> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ahh I see, yeah I wouldn't worry too much about this since it's really a Formik implementation detail..
export default { | ||
title: 'Forms/Validation', | ||
component: ValidationChecklist, | ||
ValidationItem, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
TIL you can also have subcomponents if you like that idea
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ahobson Thanks for sharing! I'm definitely going to use this. Also seems useful for a bunch of our other stories, I may do some cleanup later this week.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
Summary
Add
ValidationChecklist
andValidationItem
components. See https://designsystem.digital.gov/components/form-controls/#validationRelated Issues or PRs
#80