Skip to content
Permalink
Browse files
TCK: do nothing with non-constrained properties
  • Loading branch information
mbenson committed Oct 16, 2018
1 parent 15a3e2b commit 7a332de00e377441a6676bee90f466819d8b741f
Showing 1 changed file with 10 additions and 2 deletions.
@@ -48,6 +48,7 @@
import org.apache.bval.jsr.descriptor.ComposedD;
import org.apache.bval.jsr.descriptor.ConstraintD;
import org.apache.bval.jsr.descriptor.ContainerElementTypeD;
import org.apache.bval.jsr.descriptor.DescriptorManager;
import org.apache.bval.jsr.descriptor.ElementD;
import org.apache.bval.jsr.descriptor.PropertyD;
import org.apache.bval.jsr.metadata.ContainerElementKey;
@@ -476,7 +477,7 @@ private ValidateProperty(Strategy<T> strategy, ApacheFactoryContext validatorCon
t = value.getClass();
}
descriptor = (ElementD<?, ?>) validatorContext.getDescriptorManager().getBeanDescriptor(t);
} else {
} else if (hasWork()) {
final Class<?> propertyType = descriptor.getElementClass();
if (!TypeUtils.isInstance(value, propertyType)) {
Exceptions.raise(IllegalArgumentException::new, "%s is not an instance of %s", value, propertyType);
@@ -503,7 +504,6 @@ public ValidateProperty<T> cascade(boolean cascade) {
@Override
protected Frame<?> computeBaseFrame() {
// TODO assign bean as its own property and figure out what to do

return strategy.frame(this, propertyPath);
}

@@ -512,6 +512,14 @@ protected Class<T> getRootBeanClass() {
return rootBeanClass;
}

@Override
protected boolean hasWork() {
if (descriptor instanceof BeanDescriptor) {
return ((BeanDescriptor) descriptor).isBeanConstrained();
}
return DescriptorManager.isConstrained((PropertyDescriptor) descriptor);
}

@Override
ConstraintViolationImpl<T> createViolation(String messageTemplate, String message,
ConstraintValidatorContextImpl<T> context, PathImpl propertyPath) {

0 comments on commit 7a332de

Please sign in to comment.