My favorites | Sign in
Project Home Downloads Wiki Issues Source
Search
for

ValidationExtension  
JSR303 Validation Extension
Extension
Updated Feb 19, 2011 by u...@thomas-daily.de

Introduction

This is a simple extension to Morphia to process JSR303 Validation Annotations.

Using

Add this at the start of your application (or wherever you create your morphia instances).

new ValidationExtension(morphia);

Example

Here is a simple example using (as an example) Hibernate validation:

...
import org.hibernate.validator.constraints.Email;
...

@Entity
public class Userlike {
	@Id ObjectId id;
	@Email String email;
}

Implementation

This is a lightweight wrapper around the JSR303 API. It installs a simple global entity interceptor which listens to all life-cycle methods needed for validation. You can use any implementation of JSR303 by just adding it to the classpath.

You can look at the code here.

Dependencies

Manual

Maven

  • If you use Maven2 to manage your project, you can reference Morphia as a dependency.
    • Repo: http://morphia.googlecode.com/svn/mavenrepo/
    • Project Settings:
    • <dependency>
      	<groupId>com.google.code.morphia</groupId>
      	<artifactId>validation</artifactId>
      	<version>0.99</version>
      </dependency>
Comment by marin.ra...@adamantus.com, Jun 28, 2011

The Version that is on the maven and in the downloads is not valid, please check

Comment by fady.ma...@gmail.com, Jul 17, 2011

The correct dependency is

<dependency>
    <groupId>com.google.code.morphia</groupId>
    <artifactId>morphia-validation</artifactId>
    <version>0.99</version>
</dependency>
Comment by suchitp...@gmail.com, Dec 15, 2011

it seems the maven repository is not having the latest code , cause i cannot find the ValidationExtension class

Comment by mister...@gmail.com, Feb 16, 2012

Same thing here, where is the ValidationExtension class?

Comment by fady.ma...@gmail.com, Feb 18, 2012
import com.google.code.morphia.validation.MorphiaValidation; 

...

Morphia morphia = new Morphia();
MorphiaValidation morphiaValidation = new MorphiaValidation();
morphiaValidation.applyTo(morphia);
Comment by Cherepan...@gmail.com, Mar 10, 2012

Can you release maven artifact for latest revision?


Sign in to add a comment
Powered by Google Project Hosting