Class: Braintree::ValidationErrorCollection

### Home Classes Methods

### In Files

- lib/braintree/validation_error_collection.rb

### Parent

Object

### Methods

- #[]
- #deep_errors
- #deep_size
- #each
- #for
- #for_index
- #on
- #shallow_errors
- #size

### Included Modules

- Enumerable

### Class/Module Index

Quicksearch

- Braintree
- Braintree::AddOn
- Braintree::AddOnGateway
- Braintree::Address
- Braintree::AddressGateway
- Braintree::AdvancedSearch
- Braintree::AdvancedSearch::MultipleValueOrTextNode
- Braintree::AuthenticationError
- Braintree::AuthorizationError
- Braintree::BraintreeError
- Braintree::Configuration
- Braintree::ConfigurationError
- Braintree::CreditCard
- Braintree::CreditCard::CardType
- Braintree::CreditCard::CustomerLocation
- Braintree::CreditCardVerification
- Braintree::CreditCardVerification::Status
- Braintree::Customer
- Braintree::Discount
- Braintree::DiscountGateway
- Braintree::DownForMaintenanceError
- Braintree::ErrorCodes
- Braintree::ErrorCodes::Address
- Braintree::ErrorCodes::CreditCard
- Braintree::ErrorCodes::CreditCard::Options
- Braintree::ErrorCodes::Customer
- Braintree::ErrorCodes::Descriptor
- Braintree::ErrorCodes::SettlementBatchSummary
- Braintree::ErrorCodes::Subscription
- Braintree::ErrorCodes::Subscription::Modification
- Braintree::ErrorCodes::Transaction
- Braintree::ErrorCodes::Transaction::Options
- Braintree::ErrorResult
- Braintree::Errors
- Braintree::ForgedQueryString
- Braintree::NotFoundError
- Braintree::Plan
- Braintree::SSLCertificateError
- Braintree::ServerError
- Braintree::SettlementBatchSummary
- Braintree::SettlementBatchSummaryGateway
- Braintree::Subscription
- Braintree::Subscription::Status
- Braintree::Subscription::TrialDurationUnit
- Braintree::SuccessfulResult
- Braintree::Test
- Braintree::Test::CreditCardNumbers
- Braintree::Test::CreditCardNumbers::FailsSandboxVerification
- Braintree::Test::TransactionAmounts
- Braintree::Transaction
- Braintree::Transaction::CreatedUsing
- Braintree::Transaction::GatewayRejectionReason
- Braintree::Transaction::Source
- Braintree::Transaction::Status
- Braintree::TransparentRedirect
- Braintree::TransparentRedirectGateway
- Braintree::UnexpectedError
- Braintree::UpgradeRequiredError
- Braintree::ValidationError
- Braintree::ValidationErrorCollection
- Braintree::ValidationsFailed
- Braintree::Version

No matching classes.

# Braintree::ValidationErrorCollection

See www.braintreepayments.com/docs/ruby/general/validation_errors

### Public Instance Methods

[](index) click to toggle source

Accesses the error at the given index.

    # File lib/braintree/validation_error_collection.rb, line 16
    def [](index)
      @errors[index]
    end

deep_errors() click to toggle source

Returns an array of ValidationError objects at this level and all nested levels in the error hierarchy

    # File lib/braintree/validation_error_collection.rb, line 22
    def deep_errors
      ([@errors] + @nested.values.map { |error_collection| error_collection.deep_errors }).flatten
    end

deep_size() click to toggle source

    # File lib/braintree/validation_error_collection.rb, line 26
    def deep_size
      size + @nested.values.inject(0) { |count, error_collection| count + error_collection.deep_size }
    end

each(&block) click to toggle source

Iterates over errors at the current level. Nested errors will not be yielded.

    # File lib/braintree/validation_error_collection.rb, line 31
    def each(&block)
      @errors.each(&block)
    end

for(nested_key) click to toggle source

Returns a ValidationErrorCollection of errors nested under the given nested_key. Returns nil if there are not any errors nested under the given key.

    # File lib/braintree/validation_error_collection.rb, line 37
    def for(nested_key)
      @nested[nested_key]
    end

for_index(index) click to toggle source

    # File lib/braintree/validation_error_collection.rb, line 41
    def for_index(index)
      self.for("index_#{index}".to_sym)
    end

on(attribute) click to toggle source

Returns an array of ValidationError objects on the given attribute.

    # File lib/braintree/validation_error_collection.rb, line 50
    def on(attribute)
      @errors.select { |error| error.attribute == attribute.to_s }
    end

shallow_errors() click to toggle source

Returns an array of ValidationError objects at the given level in the error hierarchy

    # File lib/braintree/validation_error_collection.rb, line 55
    def shallow_errors
      @errors.dup
    end

size() click to toggle source

The number of errors at this level. This does not include nested errors.

    # File lib/braintree/validation_error_collection.rb, line 60
    def size
      @errors.size
    end

[Validate]

Generated with the Darkfish Rdoc Generator 2.