-
Notifications
You must be signed in to change notification settings - Fork 935
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
Is there a way to get a context inside .default(() => {...}) ? #1984
Comments
Here's how you can modify your example to use the context:
the default function takes two arguments: the first argument represents the value of the field (which is not used in this case), and the second argument represents the context object. The context.timezone property is used to get the timezone for the moment().tz() function calls. I hope this helps. |
@Edleychris thank you for your reply! Unfortunately, your code doesn't work for me (latest yup@1.1.1).
In the master, I see that getDefault has been calling without any arguments: https://github.com/jquense/yup/blob/master/src/schema.ts#L610-L620 that explains why I see a null-reference error. What |
Any news? |
@jquense Thank you very much, I hope this change will be released soon. |
The library allows specifying the context when using
getDefault
method:but I don't see any way to get a passed context inside the
field.default(() => { ... }
method. The whole example:Please help, thanks for any advice!
The text was updated successfully, but these errors were encountered: