You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Describe the bug
When using the oneOf or notOneOf with null and undefined the values are not interpolated into the error message properly.
constoneOfSchema=yup.object({name: yup.string().nullable().oneOf([null,undefined])});// "name must be one of the following values: , "// ^^ Notice the `null` and `undefined` are not "stringified" into the error message.
Expected behavior
When using null or undefined in the oneOf or notOneOf methods the error message will interpolate those values correctly.
Platform (please complete the following information):
Chrome 79 on macOS (Mojave)
Version: 0.26.10
Additional context
This may seem silly that someone would mark a schema as nullable but then also set the schema as oneOf([null]), but I have a use case where when using when I believe this makes sense.
stripe_id: yup.string().label('Stripe ID').required().nullable().when('type',(type,schema)=>{// If type is stripe, stripe_id cannot be null and must be provided// Otherwise the value must be nullreturntype==='stripe'
? schema.nullable(false)
: schema.oneOf([null]);})
The text was updated successfully, but these errors were encountered:
closes: #768#104
BREAKING CHANGE: previously `oneOf` required adding `null` explicitly to allowed values when using oneOf. Folks have found this confusing and unintuitive so I am deferring and adjusting the behavior
closes: #768#104
BREAKING CHANGE: previously `oneOf` required adding `null` explicitly to allowed values when using oneOf. Folks have found this confusing and unintuitive so I am deferring and adjusting the behavior
Describe the bug
When using the
oneOf
ornotOneOf
withnull
andundefined
the values are not interpolated into the error message properly.To Reproduce
https://codesandbox.io/s/dreamy-elgamal-7d2fv
Expected behavior
When using
null
orundefined
in theoneOf
ornotOneOf
methods the error message will interpolate those values correctly.Platform (please complete the following information):
Additional context
This may seem silly that someone would mark a schema as
nullable
but then also set the schema asoneOf([null])
, but I have a use case where when usingwhen
I believe this makes sense.The text was updated successfully, but these errors were encountered: