-
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
array().ensure() not casting single element #343
Labels
Comments
You can make it work by having the |
that sounds reasonable, happy to take a fix! |
fionawhim
pushed a commit
to CityOfBoston/yup
that referenced
this issue
Oct 17, 2018
This fixes to match the documentation, which says that a single element should get cast to an array containing that element. Previously the transform added in the constructor would convert non-arrays to null before the ensure transform function would see them. Fixes jquense#343 WARNING: This is a breaking change. `ensure` now ignores any transformations added before it, including the transform in the constructor that parses JSON.
fionawhim
pushed a commit
to CityOfBoston/yup
that referenced
this issue
Oct 17, 2018
This fixes to match the documentation, which says that a single element should get cast to an array containing that element. Previously the transform added in the constructor would convert non-arrays to null before the ensure transform function would see them. Fixes jquense#343 WARNING: This is a breaking change. `ensure` now ignores any transformations added before it, including the transform in the constructor that parses JSON.
Hi guys, there is some plan for releasing this fix ? |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
The docs for
array.ensure
say that it will cast a non-array into a single element array:However in 0.26.6 on Node, the above returns
[]
. It looks like thetransform
call in the array constructor (run withwithMutation
) runs first and sets the value tonull
when it sees it’s not an array. Therefore thetransform
method inensure
seesnull
rather than the original value.I’m happy to make a PR if I could understand what the right solution is for the fix. Are the
transform
s not being called in the right order?The text was updated successfully, but these errors were encountered: