-
Notifications
You must be signed in to change notification settings - Fork 907
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
baseSchema.concat(otherSchema) overwrites baseSchema properties when otherSchema properties are undefined #1160
Comments
After spending some time on the issue i came to this conclusion ( codesandox had problems when testing so will leave it here):
|
hmm no it's not intended. it should work like it used to. |
I coppied
|
Concatting schemas can overwrite previous non-undefined values with undefined
Describe the bug
Last_Edit: It is because of this code https://github.com/jquense/yup/blob/master/src/schema.ts#L231-L233 ,
combined.spec
has every propertyundefined
, it would work ifcombined.spec
properties were non-existent instead ofundefined
:const mergedSpec = { ...base.spec, ...combined.spec };
First_Edit: Looking a bit deeper, i am now not sure if it is caused by mixed.label(), but since the only thing we change is the yup version and this unexpected behavior occurs, i will keep this issue as is, hopefully someone experienced in yup can investigate or realize the reason why this happens.
Calling mixed.label("Custom label") does work on version 0.31.0 but not on 0.32.5+.
Example screenshots from v.0.31.0 and v.0.32.5+
v.0.31.0:
v.0.32.5+:
To Reproduce
Quite complex form logic react and formik, will try to extract the logic and edit here.
Expected behavior
I would expect the previous behavior of setting a label to work on error messages.
Platform (please complete the following information):
Additional context
Using with react + formik
The text was updated successfully, but these errors were encountered: