just my notes...

blog to recollect different kinf of data, comments, todo's, and make it easily avalaible from the web

01 abril 2010

hermes: validating properties referencing another object

2.1.5. Object graphs

The Bean Validation API does not only allow to validate single class instances but also complete object graphs. To do so, just annotate a field or property representing a reference to another object with @Valid. If the parent object is validated, all referenced objects annotated with @Valid will be validated as well (as will be their children etc.)

2.3. Validating groups

Groups allow you to restrict the set of constraints applied during validation. This makes for example wizard like validation possible where in each step only a specified subset of constraints get validated. The groups targeted are passed as var-args parameters to validate, validateProperty and validateValue. Let's have a look at an extended Car with Driver example. First we have the class Person (Example 2.12, “Person”) which has a @NotNull constraint on name. Since no group is specified for this annotation its default group is javax.validation.groups.Default.


Unknown en 0:28

No hay comentarios:

Publicar un comentario

mensaje del forulario de comentarios

‹
›
Inicio
Ver versión web

Datos personales

Unknown
Ver todo mi perfil
Con la tecnología de Blogger.