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

Bindings and failed validation #201

Conversation

platinumazure
Copy link
Contributor

Fixes #178. Note that this is potentially a breaking change.

The basic idea is that if changing the view causes a model set, and that model set fails (ostensibly due to validation errors), the previous model attribute should be copied back over into the view so that the model and view are back in sync.

If this is deemed to be too much of a breaking change, I can augment the pull request to support a new ModelBinder option to enable this behavior (e.g., revertViewOnValidationError or something similar). Just let me know.

Patch impact:

  • If this is merged as is, a release version bump (2.0.0 as of this writing) may be needed.
  • If this is controlled by a new ModelBinder option, only a major version bump (1.1.0 as of this writing) would be needed.

If this change is rejected outright (even with a ModelBinder option), I'll probably create a new pull request with just the test file (minus the last assertion), so that we have some coverage around ModelBinder plus validation. Presumably that would only need a minor version update.

@amakhrov
Copy link
Contributor

amakhrov commented Feb 9, 2015

Strictly speaking you're right - that's a breaking change. However, I'm not sure that {validate:true} was usable at all with the previous behavior, as it eventually ended up with inconsistent state of view vs model.

Still it's safer to have it as a configurable option for 1.x (so we can easily upgrade the library in the existing projects), and may be turn it on by default in the (future) 2.x release.

@platinumazure
Copy link
Contributor Author

@amakhrov Besides @theironcook I don't know who the collaborators and other decision-makers might be. If there are others, care to pull them in?

@platinumazure
Copy link
Contributor Author

@amakhrov Since you opened the original issue, did you have a chance to see if this fixes your issue? (Ignoring for the moment that it might be a "breaking change")

@platinumazure
Copy link
Contributor Author

@theironcook Could you take a look at this and weigh in on if my proposal is too much of a "breaking change"? As @amakhrov has said, using ModelBinder with model validation is pretty much useless at this point anyway.

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

Successfully merging this pull request may close these issues.

View and Model out of sync when model.validate fails
2 participants