-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
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
Next #276
Next #276
Conversation
I think field level validations seems awesome, I'm going to try it out on a form which adds fields dynamically which have been a huge pain currently for me 🍻 |
src/Field.tsx
Outdated
); | ||
} else { | ||
// Otherwise set the error | ||
setFieldError(maybePromise); |
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.
Shouldn't this be setFieldError(name, maybePromise)
? I think that this is causing an error for me...
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.
Yeah, adding name
here fixes this for me. The debugger also told me that setDeep
was being called with my error message as the path so this seems to be the culprit. I opened #290 to fix it
Will push this when tests pass |
Thank you! (tests seems to be passing now 😃) |
So, one thing to think about, which I'm not sure really how to solve, is that setting a validator on field will not rerun that validation if |
True true. Hmmmmm |
@jaredpalmer this looks great! |
@jaredpalmer it looks like when dealing nested array the required name should look like |
Yeah we need to add bracket support to dlv |
src/FieldArray.tsx
Outdated
}; | ||
const { render } = this.props; | ||
return render | ||
? (render as any)({ ...arrayHelpers, form: this.context.formik }) |
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.
form is missing in ts definition
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 yes good looks
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.
As you fix missing def, can you release a new alpha, as I'm living on the edge :D? Thank you so much!
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.
@jaredpalmer thanks 👍
@@ -639,7 +619,7 @@ function warnAboutMissingIdentifier({ | |||
* Transform Yup ValidationError to a more usable object | |||
*/ | |||
export function yupToFormErrors<Values>(yupError: any): FormikErrors<Values> { |
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.
yup is now definitively typed :) ... take a look https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/yup/index.d.ts
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.
Yah will do
* Fix FieldArray component prop * nit: test names [skip ci]
* feat(Field): Allow bracket path support * chore(deps): Add types for lodash.topath * chore(deps): yarn.lock
I just implemented an custom password input field with built-in strenght check and validation using the field-level validation and it works amazingly well, great work! Have you considered the interaction between those field-level validations and the |
To add more details to my previous comment: When I add calls to
After some debugging, it seems related to Lines 341 to 343 in 560a5e3
When there are schema errors, the errors are replaced by the one from the schema validation: Lines 348 to 350 in 560a5e3
They should be merged with errors coming from the fields (and eventually overriding them, depending on which one you want to prioritize). |
And a related error, probably masked by the behaviour I described above previously. Please tell me if you prefer separate issues about these reports. |
Merging the errors from field-level validations and validationSchema would be really useful |
I digged a bit more into this, and the real issue is merging validation results when some (or all) of them are async (either from I do not really know how to fix this properly, as you need to know when to merge (the new validation results that come in needs to be applied on top of the existing ones). Probably something like:
This is needed as we can have a new validation pass happening while some async results did not resolve yet (like if coming from a slow server-side process). As there is no way to cancel promises, we need to check if the results are current when it resolves. I might have missed something here, I am still trying to grasp the whole codebase. |
* feat(formik): Add onReset callback. * feat(formik): Use promise sniffing for onReset prop. This passes returned promise data to resetForm, allowing the promise to add new nextValues.
Okay folks, going to merge and cut a release. |
Great work 🎂 |
<FieldArray>
(for now this is bundled with core), might move toformik-array
pkg<FieldArray>