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: adds validateOnLoad #622
Conversation
Hi @jaredpalmer can we discuss before I clean up conflicts? It appears that the react team stands behind calling setState from componentDidMount: And it's not a valid eslint rule on latest react And as for the user experience, if the validation is synchronous, "the user won’t see the intermediate state" (according to the first link). If the validation is async, then presumably the validation logic implements some loading state UI. In which case it seems fitting that that loading UI would commence when the Form loads. What do you think? |
@jaredpalmer bump |
can you resolve conflicts? |
@jaredpalmer how's this? |
While this is good, it doesn't solve the use case in #622 of havin server rendered errors passed in as props. Certain errors cannot be determined by client, so having the ability to pass in |
I thought this was for initialErrors and initialTouched? |
The original post #288 mentioned either 'initialErrors' or a 'validateOnLoad' method. Both use cases could be argued for, and may be necessary, but this seems like a great addition that solves an issue a number of people are having. IMHO, I'd say that this and an 'initialErrors' prop would be two separate, and very useful, additions to the base code. In my use case, I have to make an API call to populate my initialValues, and that API call may return with my errors as well. So when the data is populated, I also need to run my custom validate method to retrieve the errors from the JSON response and apply them to the form. Just throwing in my $0.02. |
@jaredpalmer bump |
@jaredpalmer thoughts? |
@jaredpalmer beginning to feel: |
Any status on this? Even if its no way, definitely not going to do it? |
Is there some estimate on when this might get merged? There are possible cases where some form fields are no longer valid and you should prevent saving (even though they were at the time of first submit). We need to resort to some hacks to get around this, and having this PR merged would solve all the problems. |
@jaredpalmer @morgs32 we have a use case for this in production and would appreciate an update here. Ideally a merge, or at least a recap on pending issues that are blocking merge. |
@hyperboreans @vedraan just to be clear I'd love for this to be merged too. @jaredpalmer is a busy guy I guess - or he's just ghosting us til we stop asking. Meanwhile I forked this and manage my own - my therapist says I've got to move on. |
This looks like exactly what I'm after can we get it merged? |
@jaredpalmer any plans for merging this soon? Also intend to use this and would be great to fetch from npm. Thanks |
哈哈哈
| |
chang
邮箱:ssh_github@163.com
|
Signature is customized by Netease Mail Master
On 11/15/2018 11:55, DVassilev wrote:
@jaredpalmer any plans for merging this soon? Also intend to use this and would be great to fetch from npm. Thanks
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub, or mute the thread.
|
This is nice but wouldn't it be problematic without editing how Edit: Fixed link |
In v2, validation is fired on mount by default. |
@jaredpalmer Does this mean you will also deprecate |
@@ -31,6 +31,7 @@ export class Formik<Values = {}, ExtraProps = {}> extends React.Component< | |||
static defaultProps = { | |||
validateOnChange: true, | |||
validateOnBlur: true, | |||
validateOnLoad: false, |
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.
How about validateOnMount
. It is not clear when "load" happens
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.
Agree. Btw this is on by default in v2
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.
Is now a good time to use v2?
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.
YES
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.
validateOnMount makes the most sense
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 am using v2.0.1-rc.12 but there is still not validateOnLoad flag. Any idea when this very important feature will be released?
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.
Likewise, forms aren't validating on mount using v2.0.1-rc.13. Is the expectation that we have to setInitialErrors
despite guidance above indicating that Formik validates on mount by default in v2?
Added back to v2 here: #1913 The default is false. |
Resolves #288