Showing posts with label validation. Show all posts
Showing posts with label validation. Show all posts

Tuesday, March 25, 2008

Validation Framework for java

Wouldn't it be nice to be able to do something like this:
public class Address {

@NotEmpty @Max(50)
private String street1;

@Max(50)
private String street2;

@Max(9) @NotNull
private String zipcode;

...

}

and then be able to say something like:
public class Order {
@Valid @NotNull private Address delivery;
}

The implications of something like this go beyond mere validation. IMHO it si an elegant solution that if built properly will improve the DRYness of the code across all layers of any java application.

This is the intention behind jsr-303. .