As well as accessing the props in validationSchema is it possible to get the current values? I'm wanting a way to define the validation dynamically based on the values selected by the user.
e.g.
validationSchema?: Schema | ((props: Props) => Schema)
// becomes
validationSchema?: Schema | ((values: Values, props: Props) => Schema)
happy to submit a PR if you're interested in this.
Hi Dave
Is yup.lazy enough to solve your problem?
https://github.com/jquense/yup/blob/master/README.md#yuplazyvalue-any--schema-lazy
On Wed, 30 Aug 2017 at 00:23 Dave Timmins notifications@github.com wrote:
As well as accessing the props in validationSchema is it possible to get
the current values? I'm wanting a way to define the validation dynamically
based on the values selected by the user.e.g.
validationSchema?: Schema | ((props: Props) => Schema)// becomes
validationSchema?: Schema | ((values: Values, props: Props) => Schema)happy to submit a PR if you're interested in this.
โ
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
https://github.com/jaredpalmer/formik/issues/145, or mute the thread
https://github.com/notifications/unsubscribe-auth/AAFj60XxOsLDgusTVRG3AZ1eqX3_eHpIks5sdOPPgaJpZM4PG2Z2
.
Yes it is thanks!
so if anyone is interested it's now
validationSchema: props => {
return Yup.lazy(values => {
return Yup.object().shape({
whereas before it was
validationSchema: props =>
Yup.object().shape({
๐๐๐
On Wed, 30 Aug 2017 at 05:49 Dave Timmins notifications@github.com wrote:
Closed #145 https://github.com/jaredpalmer/formik/issues/145.
โ
You are receiving this because you commented.Reply to this email directly, view it on GitHub
https://github.com/jaredpalmer/formik/issues/145#event-1227272474, or mute
the thread
https://github.com/notifications/unsubscribe-auth/AAFj64mgA77ie2nKnuvs1FEdfa16JLrNks5sdTAigaJpZM4PG2Z2
.
@davetimmins Sounds good!!
Most helpful comment
Yes it is thanks!
so if anyone is interested it's now
whereas before it was