Package ninja.validation
Class ValidationImpl
- java.lang.Object
-
- ninja.validation.ValidationImpl
-
- All Implemented Interfaces:
Validation
public class ValidationImpl extends Object implements Validation
Validation object- Author:
- James Roper, Philip Sommer, Jonathan Lannoy
-
-
Constructor Summary
Constructors Constructor Description ValidationImpl()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addBeanViolation(FieldViolation fieldViolation)
Add a bean violation.void
addFieldViolation(String field, ConstraintViolation constraintViolation)
Add a violation to the given fieldvoid
addFieldViolation(FieldViolation fieldViolation)
Add a field violation to the list of filed violations.void
addViolation(ConstraintViolation violation)
Add a violationList<FieldViolation>
getBeanViolations()
Get all bean validations for that bean.List<FieldViolation>
getBeanViolations(String field)
Get a complete list of bean violations for a specified field.List<FieldViolation>
getFieldViolations()
Get a complete list of all field violations.List<FieldViolation>
getFieldViolations(String field)
Get a complete list of field violations for a specified field.List<ConstraintViolation>
getGeneralViolations()
Get all general constraint violations.List<ConstraintViolation>
getViolations()
Get all constraint violations.List<ConstraintViolation>
getViolations(String paramName)
Get a complete list of field violations for a specified parameter.boolean
hasBeanViolation(String field)
Checks if the validation has bean violation.boolean
hasBeanViolations()
Whether any violation occured while validating your beans Note: For now, you can only have one bean in your controller method signature, so this is explicit.boolean
hasFieldViolation(String field)
Whether the validation context has a violation for the given fieldboolean
hasViolation(String paramName)
Whether the validation context has a violation for the given fieldboolean
hasViolations()
Whether the validation context has violations (including field and bean violations)
-
-
-
Method Detail
-
hasViolations
public boolean hasViolations()
Description copied from interface:Validation
Whether the validation context has violations (including field and bean violations)- Specified by:
hasViolations
in interfaceValidation
- Returns:
- True if it does
-
hasViolation
public boolean hasViolation(String paramName)
Description copied from interface:Validation
Whether the validation context has a violation for the given field- Specified by:
hasViolation
in interfaceValidation
- Returns:
- True if it does
-
getViolations
public List<ConstraintViolation> getViolations()
Description copied from interface:Validation
Get all constraint violations.- Specified by:
getViolations
in interfaceValidation
- Returns:
- The list of all violations.
-
getViolations
public List<ConstraintViolation> getViolations(String paramName)
Description copied from interface:Validation
Get a complete list of field violations for a specified parameter.- Specified by:
getViolations
in interfaceValidation
- Returns:
- A List of FieldViolation-objects
-
addViolation
public void addViolation(ConstraintViolation violation)
Description copied from interface:Validation
Add a violation- Specified by:
addViolation
in interfaceValidation
- Parameters:
violation
- The constraint violation
-
addFieldViolation
public void addFieldViolation(FieldViolation fieldViolation)
Description copied from interface:Validation
Add a field violation to the list of filed violations.- Specified by:
addFieldViolation
in interfaceValidation
-
addFieldViolation
public void addFieldViolation(String field, ConstraintViolation constraintViolation)
Description copied from interface:Validation
Add a violation to the given field- Specified by:
addFieldViolation
in interfaceValidation
- Parameters:
field
- The field to add the violation toconstraintViolation
- The constraint violation
-
hasFieldViolation
public boolean hasFieldViolation(String field)
Description copied from interface:Validation
Whether the validation context has a violation for the given field- Specified by:
hasFieldViolation
in interfaceValidation
- Returns:
- True if it does
-
getFieldViolations
public List<FieldViolation> getFieldViolations()
Description copied from interface:Validation
Get a complete list of all field violations. This list DOES NOT contain general violations (use getGeneralViolations() instead).- Specified by:
getFieldViolations
in interfaceValidation
- Returns:
- A List of FieldViolation-objects
-
getFieldViolations
public List<FieldViolation> getFieldViolations(String field)
Description copied from interface:Validation
Get a complete list of field violations for a specified field. This list DOES NOT contain general violations (use getGeneralViolations() instead).- Specified by:
getFieldViolations
in interfaceValidation
- Returns:
- A List of FieldViolation-objects
-
addBeanViolation
public void addBeanViolation(FieldViolation fieldViolation)
Description copied from interface:Validation
Add a bean violation. A bean, like a DTO consists of several fields which are validated. Each validation error of a dto-field results in a field-violation for that bean. Note: For now, you can only have one bean in your controller method signature, so this is explicit.- Specified by:
addBeanViolation
in interfaceValidation
- Parameters:
fieldViolation
- the FieldViolation consisting of a cinstraintViolation and the fields name
-
hasBeanViolation
public boolean hasBeanViolation(String field)
Description copied from interface:Validation
Checks if the validation has bean violation.- Specified by:
hasBeanViolation
in interfaceValidation
- Parameters:
field
- Name of the bean.- Returns:
- Whether the named bean has violation.
-
hasBeanViolations
public boolean hasBeanViolations()
Description copied from interface:Validation
Whether any violation occured while validating your beans Note: For now, you can only have one bean in your controller method signature, so this is explicit.- Specified by:
hasBeanViolations
in interfaceValidation
- Returns:
- true if there are any, false if none
-
getBeanViolations
public List<FieldViolation> getBeanViolations()
Description copied from interface:Validation
Get all bean validations for that bean. Note: For now, you can only have one bean in your controller method signature, so this is explicit.- Specified by:
getBeanViolations
in interfaceValidation
- Returns:
- A list of field violations
-
getBeanViolations
public List<FieldViolation> getBeanViolations(String field)
Description copied from interface:Validation
Get a complete list of bean violations for a specified field. This list DOES NOT contain general violations (use getGeneralViolations() instead).- Specified by:
getBeanViolations
in interfaceValidation
- Returns:
- A List of FieldViolation-objects
-
getGeneralViolations
public List<ConstraintViolation> getGeneralViolations()
Description copied from interface:Validation
Get all general constraint violations. This list does not contain any specific field violation (use getFieldViolations() instead).- Specified by:
getGeneralViolations
in interfaceValidation
- Returns:
- The list of general violations.
-
-