public interface Validation
ValidationImpl
) and can be injected in your
controller method.
There are several types of violations that can occur: field violations (on controller method fields), bean violations
(on an injected beans field) or general violations (deprecated). A controller using this validation can have
violations on his
parameters or, if you use a injected data container like a DTO or bean, you may have violations inside this object.
Each violation on a field (parameter or in an annotated bean) results in a FieldViolation
. This makes it
possible to validate all controller parameters at once. If an error appears while validating the controller
method parameters, it results in a violation which you can get using getFieldViolations().
If your injected bean contains violations, you should use getBeanViolations().Modifier and Type | Method and Description |
---|---|
void |
addBeanViolation(FieldViolation fieldViolation)
Deprecated.
|
void |
addFieldViolation(FieldViolation fieldViolation)
Deprecated.
|
void |
addFieldViolation(String field,
ConstraintViolation constraintViolation)
Deprecated.
|
void |
addViolation(ConstraintViolation constraintViolation)
Add a violation
|
List<FieldViolation> |
getBeanViolations()
Deprecated.
|
List<FieldViolation> |
getBeanViolations(String fieldName)
Deprecated.
|
List<FieldViolation> |
getFieldViolations()
Deprecated.
|
List<FieldViolation> |
getFieldViolations(String fieldName)
Deprecated.
|
List<ConstraintViolation> |
getGeneralViolations()
Deprecated.
|
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 name)
Deprecated.
|
boolean |
hasBeanViolations()
Deprecated.
|
boolean |
hasFieldViolation(String field)
Deprecated.
|
boolean |
hasViolation(String paramName)
Whether the validation context has a violation for the given field
|
boolean |
hasViolations()
Whether the validation context has violations (including field and bean violations)
|
boolean hasViolations()
boolean hasViolation(String paramName)
List<ConstraintViolation> getViolations()
List<ConstraintViolation> getViolations(String paramName)
void addViolation(ConstraintViolation constraintViolation)
constraintViolation
- The constraint violation@Deprecated boolean hasFieldViolation(String field)
@Deprecated void addFieldViolation(String field, ConstraintViolation constraintViolation)
field
- The field to add the violation toconstraintViolation
- The constraint violation@Deprecated List<FieldViolation> getFieldViolations()
@Deprecated List<FieldViolation> getFieldViolations(String fieldName)
@Deprecated List<ConstraintViolation> getGeneralViolations()
@Deprecated void addFieldViolation(FieldViolation fieldViolation)
fieldViolation
- @Deprecated void addBeanViolation(FieldViolation fieldViolation)
beanName
- maybe the name of your dtofieldViolation
- the FieldViolation consisting of a cinstraintViolation and the fields
name@Deprecated boolean hasBeanViolation(String name)
name
- Name of the bean.@Deprecated boolean hasBeanViolations()
@Deprecated List<FieldViolation> getBeanViolations()
beanName
- @Deprecated List<FieldViolation> getBeanViolations(String fieldName)
Copyright © 2019 ninjaframework. All rights reserved.