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

Make Model.validate() use castObject() to cast, and also not modify the object in place #12668

Closed
2 tasks done
vkarpov15 opened this issue Nov 8, 2022 · 0 comments
Closed
2 tasks done
Labels
discussion If you have any thoughts or comments on this issue, please share them! enhancement This issue is a user-facing general improvement that doesn't fix a bug or add a new feature
Milestone

Comments

@vkarpov15
Copy link
Collaborator

Prerequisites

  • I have written a descriptive issue title
  • I have searched existing issues to ensure the issue has not already been raised

Issue

Model.castObject(obj) casts obj and returns a copy if casting succeeded. Model.validate(obj) casts and validates obj, but modifies obj in place if casting succeeded.

This behavior is inconsistent, and I think we should either (1) make validate() not run casting, or (2) make validate() return a casted copy. The major reason for returning a copy instead of modifying the object in place is to avoid only applying casting halfway if casting fails. If there's a cast error, some of the paths in obj won't be casted.

@vkarpov15 vkarpov15 added enhancement This issue is a user-facing general improvement that doesn't fix a bug or add a new feature discussion If you have any thoughts or comments on this issue, please share them! labels Nov 8, 2022
@vkarpov15 vkarpov15 added this to the 7.0 milestone Nov 8, 2022
@vkarpov15 vkarpov15 modified the milestones: 7.0, Parking Lot Feb 13, 2023
@vkarpov15 vkarpov15 modified the milestones: Parking Lot, 8.0 Jun 21, 2023
vkarpov15 added a commit that referenced this issue Sep 5, 2023
…cast, and return casted copy of object instead of modifying in place

Fix #12668
vkarpov15 added a commit that referenced this issue Sep 8, 2023
BREAKING CHANGE: make `Model.validate()` use `Model.castObject()` to cast, and return casted copy of object instead of modifying in place
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
discussion If you have any thoughts or comments on this issue, please share them! enhancement This issue is a user-facing general improvement that doesn't fix a bug or add a new feature
Projects
None yet
Development

No branches or pull requests

1 participant