Search in sources :

Example 1 with MinijaxPropertyDescriptor

use of org.minijax.validator.metadata.MinijaxPropertyDescriptor in project minijax by minijax.

the class MinijaxValidator method validate.

@Override
public <T> Set<ConstraintViolation<T>> validate(final T object, final Class<?>... groups) {
    final MinijaxConstraintValidatorContext<T> context = new MinijaxConstraintValidatorContext<>(object);
    final BeanDescriptor descriptor = getConstraintsForClass(object.getClass());
    for (final PropertyDescriptor propertyDescriptor : descriptor.getConstrainedProperties()) {
        final Object value = ((MinijaxPropertyDescriptor) propertyDescriptor).getValue(object);
        validateProperty(context, propertyDescriptor, value);
    }
    return context.getResult();
}
Also used : MinijaxPropertyDescriptor(org.minijax.validator.metadata.MinijaxPropertyDescriptor) PropertyDescriptor(javax.validation.metadata.PropertyDescriptor) MinijaxPropertyDescriptor(org.minijax.validator.metadata.MinijaxPropertyDescriptor) MinijaxBeanDescriptor(org.minijax.validator.metadata.MinijaxBeanDescriptor) BeanDescriptor(javax.validation.metadata.BeanDescriptor)

Example 2 with MinijaxPropertyDescriptor

use of org.minijax.validator.metadata.MinijaxPropertyDescriptor in project minijax by minijax.

the class MinijaxValidator method validateProperty.

@Override
public <T> Set<ConstraintViolation<T>> validateProperty(final T object, final String propertyName, final Class<?>... groups) {
    final MinijaxConstraintValidatorContext<T> context = new MinijaxConstraintValidatorContext<>(object);
    final BeanDescriptor descriptor = getConstraintsForClass(object.getClass());
    final PropertyDescriptor propertyDescriptor = descriptor.getConstraintsForProperty(propertyName);
    final Object value = ((MinijaxPropertyDescriptor) propertyDescriptor).getValue(object);
    validateProperty(context, propertyDescriptor, value);
    return context.getResult();
}
Also used : MinijaxPropertyDescriptor(org.minijax.validator.metadata.MinijaxPropertyDescriptor) PropertyDescriptor(javax.validation.metadata.PropertyDescriptor) MinijaxPropertyDescriptor(org.minijax.validator.metadata.MinijaxPropertyDescriptor) MinijaxBeanDescriptor(org.minijax.validator.metadata.MinijaxBeanDescriptor) BeanDescriptor(javax.validation.metadata.BeanDescriptor)

Aggregations

BeanDescriptor (javax.validation.metadata.BeanDescriptor)2 PropertyDescriptor (javax.validation.metadata.PropertyDescriptor)2 MinijaxBeanDescriptor (org.minijax.validator.metadata.MinijaxBeanDescriptor)2 MinijaxPropertyDescriptor (org.minijax.validator.metadata.MinijaxPropertyDescriptor)2