Why yet another Java validation framework?

This project started as an attemp to explore internal domain specific languages in Java, after reading the paper Evolving an Embedded Domain-Specific Language in Java, by Steve Freeman and Nat Pryce (OOPSLA 2006).

The project's goal is to provide a simple, pure Java, validator with an API that is easy to read, easy to program and feels like a special purpose validation language.

[top]

How do I use the validation DSL?

Use the BeanValidator and import all the static methods from the Validators class.

          import static com.tzavellas.validation.Validators.*;
          import com.tzavellas.validation.BeanValidator;
          
          BeanValidator validator = new BeanValidator(
                    string("firstName").required(),
                    string("lastName").required(),
                    string("email").required().email(),
                    integer("age").min(18),
                    date("birthdate").past());
         

[top]

Are BeanValidator instances thread-safe?

Yes, multiple threads can access concurrently the same BeanValidator instance.

[top]

Can I use this library with the Spring Framework and Spring-MVC?

Yes!

See the SpringValidator's documentation for more details.

[top]