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 voidaddBeanViolation(FieldViolation fieldViolation)Add a bean violation.voidaddFieldViolation(String field, ConstraintViolation constraintViolation)Add a violation to the given fieldvoidaddFieldViolation(FieldViolation fieldViolation)Add a field violation to the list of filed violations.voidaddViolation(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.booleanhasBeanViolation(String field)Checks if the validation has bean violation.booleanhasBeanViolations()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.booleanhasFieldViolation(String field)Whether the validation context has a violation for the given fieldbooleanhasViolation(String paramName)Whether the validation context has a violation for the given fieldbooleanhasViolations()Whether the validation context has violations (including field and bean violations)
-
-
-
Method Detail
-
hasViolations
public boolean hasViolations()
Description copied from interface:ValidationWhether the validation context has violations (including field and bean violations)- Specified by:
hasViolationsin interfaceValidation- Returns:
- True if it does
-
hasViolation
public boolean hasViolation(String paramName)
Description copied from interface:ValidationWhether the validation context has a violation for the given field- Specified by:
hasViolationin interfaceValidation- Returns:
- True if it does
-
getViolations
public List<ConstraintViolation> getViolations()
Description copied from interface:ValidationGet all constraint violations.- Specified by:
getViolationsin interfaceValidation- Returns:
- The list of all violations.
-
getViolations
public List<ConstraintViolation> getViolations(String paramName)
Description copied from interface:ValidationGet a complete list of field violations for a specified parameter.- Specified by:
getViolationsin interfaceValidation- Returns:
- A List of FieldViolation-objects
-
addViolation
public void addViolation(ConstraintViolation violation)
Description copied from interface:ValidationAdd a violation- Specified by:
addViolationin interfaceValidation- Parameters:
violation- The constraint violation
-
addFieldViolation
public void addFieldViolation(FieldViolation fieldViolation)
Description copied from interface:ValidationAdd a field violation to the list of filed violations.- Specified by:
addFieldViolationin interfaceValidation
-
addFieldViolation
public void addFieldViolation(String field, ConstraintViolation constraintViolation)
Description copied from interface:ValidationAdd a violation to the given field- Specified by:
addFieldViolationin interfaceValidation- Parameters:
field- The field to add the violation toconstraintViolation- The constraint violation
-
hasFieldViolation
public boolean hasFieldViolation(String field)
Description copied from interface:ValidationWhether the validation context has a violation for the given field- Specified by:
hasFieldViolationin interfaceValidation- Returns:
- True if it does
-
getFieldViolations
public List<FieldViolation> getFieldViolations()
Description copied from interface:ValidationGet a complete list of all field violations. This list DOES NOT contain general violations (use getGeneralViolations() instead).- Specified by:
getFieldViolationsin interfaceValidation- Returns:
- A List of FieldViolation-objects
-
getFieldViolations
public List<FieldViolation> getFieldViolations(String field)
Description copied from interface:ValidationGet a complete list of field violations for a specified field. This list DOES NOT contain general violations (use getGeneralViolations() instead).- Specified by:
getFieldViolationsin interfaceValidation- Returns:
- A List of FieldViolation-objects
-
addBeanViolation
public void addBeanViolation(FieldViolation fieldViolation)
Description copied from interface:ValidationAdd 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:
addBeanViolationin interfaceValidation- Parameters:
fieldViolation- the FieldViolation consisting of a cinstraintViolation and the fields name
-
hasBeanViolation
public boolean hasBeanViolation(String field)
Description copied from interface:ValidationChecks if the validation has bean violation.- Specified by:
hasBeanViolationin interfaceValidation- Parameters:
field- Name of the bean.- Returns:
- Whether the named bean has violation.
-
hasBeanViolations
public boolean hasBeanViolations()
Description copied from interface:ValidationWhether 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:
hasBeanViolationsin interfaceValidation- Returns:
- true if there are any, false if none
-
getBeanViolations
public List<FieldViolation> getBeanViolations()
Description copied from interface:ValidationGet 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:
getBeanViolationsin interfaceValidation- Returns:
- A list of field violations
-
getBeanViolations
public List<FieldViolation> getBeanViolations(String field)
Description copied from interface:ValidationGet a complete list of bean violations for a specified field. This list DOES NOT contain general violations (use getGeneralViolations() instead).- Specified by:
getBeanViolationsin interfaceValidation- Returns:
- A List of FieldViolation-objects
-
getGeneralViolations
public List<ConstraintViolation> getGeneralViolations()
Description copied from interface:ValidationGet all general constraint violations. This list does not contain any specific field violation (use getFieldViolations() instead).- Specified by:
getGeneralViolationsin interfaceValidation- Returns:
- The list of general violations.
-
-