Package de.isas.mztab2.validation
Class MzTabBeanValidator
- java.lang.Object
-
- de.isas.mztab2.validation.MzTabBeanValidator
-
public class MzTabBeanValidator extends Object implements Validator<MzTab>
This validator used the HibernateValidator bean validation reference implementation. It understands the standard annotations that are placed on the domain objects generated from Swagger Codegen.
- Author:
- nilshoffmann
-
-
Constructor Summary
Constructors Constructor Description MzTabBeanValidator()Default constructor.MzTabBeanValidator(boolean failFast)Constructor setting up the validator configuration and default constraint mapping.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description <A extends Annotation,T,V extends javax.validation.ConstraintValidator<A,T>>
voidaddConstraintAndValidator(Class<A> constraintDefinition, Class<V> validator, boolean includeExistingValidators)Allows registration of custom constraint / validator pairs on the validation configuration.<A extends Annotation,T,V extends javax.validation.ConstraintValidator<A,T>>
voidaddConstraintAndValidator(Class<T> typeToValidate, Class<A> constraintDefinition, Class<V> validator, boolean includeExistingValidators)Allows registration of custom constraint / validator pairs on the validation configuration for a specific (unannotated) type.protected StringgetPathLocatorString(javax.validation.ConstraintViolation<?> cv)getPathLocatorString.List<ValidationMessage>validate(MzTab mzTab)validate.
-
-
-
Constructor Detail
-
MzTabBeanValidator
public MzTabBeanValidator()
Default constructor. Fail fast validation is disabled.
-
MzTabBeanValidator
public MzTabBeanValidator(boolean failFast)
Constructor setting up the validator configuration and default constraint mapping.- Parameters:
failFast- if true, first validation error will terminate any further validation. If false, validation will continue and report all validation errors.
-
-
Method Detail
-
addConstraintAndValidator
public <A extends Annotation,T,V extends javax.validation.ConstraintValidator<A,T>> void addConstraintAndValidator(Class<A> constraintDefinition, Class<V> validator, boolean includeExistingValidators)
Allows registration of custom constraint / validator pairs on the validation configuration. This requires that the objects to be validated are annotated with the corresponding constraint definition.- Type Parameters:
A- The annotation marking elements that should be validated.T- The Object type on which the validation should be performed.V- The validator to use for the validation.- Parameters:
constraintDefinition- The annotation marking elements that should be validated.validator- The validator to use for the validation.includeExistingValidators- If true, existing validators for the same type will be applied, too. If false, only the registered validator will be retained for that type.
-
addConstraintAndValidator
public <A extends Annotation,T,V extends javax.validation.ConstraintValidator<A,T>> void addConstraintAndValidator(Class<T> typeToValidate, Class<A> constraintDefinition, Class<V> validator, boolean includeExistingValidators)
Allows registration of custom constraint / validator pairs on the validation configuration for a specific (unannotated) type.- Type Parameters:
A- The annotation marking elements that should be validated.T- The Object type on which the validation should be performed.V- The validator to use for the validation.- Parameters:
typeToValidate- The class/type that should be validated.constraintDefinition- The annotation marking elements that should be validated.validator- The validator to use for the validation.includeExistingValidators- If true, existing validators for the same type will be applied, too. If false, only the registered validator will be retained for that type.
-
validate
public List<ValidationMessage> validate(MzTab mzTab)
validate.
Please make sure that all exceptions are caught within the validate method!
-
getPathLocatorString
protected String getPathLocatorString(javax.validation.ConstraintViolation<?> cv)
getPathLocatorString.
- Parameters:
cv- aConstraintViolationobject.- Returns:
- a
Stringobject.
-
-