public class ValidationErrors extends Object
TransactionRequest request = new TransactionRequest(). amount(null). ResultFor more detailed information onresult = 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());
ValidationErrors
, see http://www.braintreepayments.com/gateway/validation-errors
Modifier and Type | Field and Description |
---|---|
private List<ValidationError> |
errors |
private Map<String,ValidationErrors> |
nestedErrors |
Constructor and Description |
---|
ValidationErrors() |
ValidationErrors(NodeWrapper node) |
Modifier and Type | Method and Description |
---|---|
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.
|
private List<ValidationError> errors
private Map<String,ValidationErrors> nestedErrors
public ValidationErrors()
public ValidationErrors(NodeWrapper node)
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()
Copyright © 2013-2017. All Rights Reserved.