Skip to content
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

Would a post-validation transform option be useful? #1442

Open
davemateer opened this issue Aug 18, 2021 · 0 comments
Open

Would a post-validation transform option be useful? #1442

davemateer opened this issue Aug 18, 2021 · 0 comments

Comments

@davemateer
Copy link

This is related to closed issue #1153 . We are experiencing the same issue with dates, and workarounds are proving a lot more "hacky" than we would like. While I understand what yup is doing, it would be nice to isolate its changing of the input value to only supporting the validation, but to be able to transform the input back into the expected format before processing downstream. The issue is that an ISO date only string (ex. "2021-04-01") comes back from yup as a time-zone-assigned date/time object, which is semantically a different thing. When this is serialized to JSON, it is possible that a server processing in UTC could interpret this as a different date entirely. (Again, there are workarounds here, but the cleanest solution would involve not propagating the reassignment of the input out of yup.

I'd be willing to take a swing at a pull request to add something like a postValidationTransform (see codesandbox example) but without being at all familiar with the yup library internal, would this even be feasible or desired? Or would this be outside the scope of what this library is intended to achieve?

https://codesandbox.io/s/sweet-faraday-15x8g

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant