Skip to content

DATAMONGO-36 - Validation support to MongoTemplate #2

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

Closed

Conversation

maciejwalkowiak
Copy link

Added JSR-303 validation support to MongoTemplate. Once validating event listener is registered it is automatically invoked before objects are saved in database.

Automatic component registration via XML namespace will be added soon in separate pull request after this one is accepted. Changes are already made in another branch: https://github.com/maciejwalkowiak/spring-data-mongodb/tree/DATAMONGO-36-namespace

@odrotbohm
Copy link
Member

Cool stuff! Here are some minor things I'd like to see before I pull this stuff in and do the final polishing:

  1. Rename BeforeSaveValidator to ValidatingMongoEventListener.
  2. Use constructor injection and a final field for the Validator in the listener implementation (removes the need for InitializingBean)
  3. Adapt BeanDefinitionParser accordingly.
  4. Instead of introducing a new namespace element please simply add a disable-validation flag to <mongo:mapping-converter /> to turn validation off. This is to align with the semantics of <mvc:annotation-driven />. <mongo:mapping-converter /> is pretty much the analogous element.

Beyond that, this is very cool already. Thanks a ton!

Maciej Walkowiak added 2 commits April 27, 2012 12:07
- changed class name to ValidatingMongoEventListener
- replaced namespace validation-enabled to flag disable-validation in mongo:mapping-converter
- added integration tests
- minor fixes
@maciejwalkowiak
Copy link
Author

I am still learning how to use git properly and because of that commit f4f9e3b was made by accident (and it's message does not make much sense).

All requested changes applied. Thanks for good advices - I hope its now as it should be.

@odrotbohm
Copy link
Member

No need to be overly concerned about that. I'll go ahead and squash all commits into one before merging them back anyway. Changes look good, I'll have a go on that in a few minutes. Thanks a ton for the contribution. Would you mind filling out the form over here and post the sign-up number you get as confirmation back here in the comments? It's basically a formal way to allow us using your contribution under Apache V2.0 license.

@maciejwalkowiak
Copy link
Author

Confirmation number is: 25320120427042238

@odrotbohm
Copy link
Member

Brilliant, thanks!

@odrotbohm
Copy link
Member

I just pushed a squashed and polished commit of your changes to the master branch. See 5b13307 for details. Thanks again for the contribution!

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.

2 participants