|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectcom.braintreegateway.ValidationErrors
public class ValidationErrors
Represents a collection of (nested) validation errors. Query for validation errors by object and field. For Example:
TransactionRequest request = new TransactionRequest().
amount(null).
Result result = gateway.transaction().sale(request);
Assert.assertFalse(result.isSuccess());
ValidationErrors errors = result.getErrors();
Assert.assertEquals(ValidationErrorCode.TRANSACTION_AMOUNT_IS_REQUIRED, errors.forObject("transaction").onField("amount").get(0).getCode());
For more detailed information on ValidationErrors, see http://www.braintreepayments.com/gateway/validation-errors
| Field Summary | |
|---|---|
private List<ValidationError> |
errors
|
private Map<String,ValidationErrors> |
nestedErrors
|
| Constructor Summary | |
|---|---|
ValidationErrors()
|
|
ValidationErrors(NodeWrapper node)
|
|
| Method Summary | |
|---|---|
void |
addError(ValidationError error)
|
void |
addErrors(String objectName,
ValidationErrors errors)
|
int |
deepSize()
Returns the number of errors on this object and all nested objects. |
ValidationErrors |
forIndex(int index)
|
ValidationErrors |
forObject(String objectName)
Returns a ValidationErrors representing nested errors for the
given ojbectName. |
List<ValidationError> |
getAllDeepValidationErrors()
Returns a List of all of the ValidationError on this object and
all nested objects. |
List<ValidationError> |
getAllValidationErrors()
Returns a List of all of the ValidationError objects at the
current nesting level. |
List<ValidationError> |
onField(String fieldName)
Returns a List of ValidationError objects for the given field. |
private void |
populateErrors(NodeWrapper node)
|
private void |
populateTopLevelErrors(List<NodeWrapper> childErrors)
|
int |
size()
Returns the number of errors on this object at the current nesting level. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
private List<ValidationError> errors
private Map<String,ValidationErrors> nestedErrors
| Constructor Detail |
|---|
public ValidationErrors()
public ValidationErrors(NodeWrapper node)
| Method Detail |
|---|
public void addError(ValidationError error)
public void addErrors(String objectName,
ValidationErrors errors)
public int deepSize()
size()public ValidationErrors forIndex(int index)
public ValidationErrors forObject(String objectName)
ValidationErrors representing nested errors for the
given ojbectName.
objectName - the name of the object with nested validation errors, e.g.
customer or creditCard.
ValidationErrors object.public List<ValidationError> getAllDeepValidationErrors()
ValidationError on this object and
all nested objects.
ValidationError objects.public List<ValidationError> getAllValidationErrors()
ValidationError objects at the
current nesting level.
ValidationError objects.public List<ValidationError> onField(String fieldName)
ValidationError objects for the given field.
fieldName - the name of the field with errors, e.g. amount or
expirationDate.
ValidationError objectsprivate void populateErrors(NodeWrapper node)
private void populateTopLevelErrors(List<NodeWrapper> childErrors)
public int size()
deepSize()
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||