jodd.vtor.constraint.AssertValidConstraint Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of jodd-vtor Show documentation
Show all versions of jodd-vtor Show documentation
Jodd VTor is focused validation framework for any Java object.
// Copyright (c) 2003-2014, Jodd Team (jodd.org). All Rights Reserved.
package jodd.vtor.constraint;
import jodd.vtor.ValidationConstraint;
import jodd.vtor.ValidationConstraintContext;
import jodd.vtor.ValidationContext;
/**
* Special annotation that validates inner context of provided value.
*/
public class AssertValidConstraint implements ValidationConstraint {
protected final ValidationContext targetValidationContext;
public AssertValidConstraint(ValidationContext targetValidationContext) {
this.targetValidationContext = targetValidationContext;
}
// ---------------------------------------------------------------- config
public void configure(AssertValid annotation) {
}
// ---------------------------------------------------------------- valid
/**
* Invokes validation on inner context. Always returns true
since
* inner context violations will be appended to provided validator.
*/
public boolean isValid(ValidationConstraintContext vcc, Object value) {
if (value == null) {
return true;
}
vcc.validateWithin(targetValidationContext, value);
return true;
}
}