Search in sources :

Example 1 with MinijaxPropertyDescriptor

use of org.minijax.validation.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.validation.metadata.MinijaxPropertyDescriptor) PropertyDescriptor(jakarta.validation.metadata.PropertyDescriptor) MinijaxPropertyDescriptor(org.minijax.validation.metadata.MinijaxPropertyDescriptor) BeanDescriptor(jakarta.validation.metadata.BeanDescriptor) MinijaxBeanDescriptor(org.minijax.validation.metadata.MinijaxBeanDescriptor)

Example 2 with MinijaxPropertyDescriptor

use of org.minijax.validation.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.validation.metadata.MinijaxPropertyDescriptor) PropertyDescriptor(jakarta.validation.metadata.PropertyDescriptor) MinijaxPropertyDescriptor(org.minijax.validation.metadata.MinijaxPropertyDescriptor) BeanDescriptor(jakarta.validation.metadata.BeanDescriptor) MinijaxBeanDescriptor(org.minijax.validation.metadata.MinijaxBeanDescriptor)

Aggregations

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