Class: Cuprum::Collections::Errors::FailedValidation

Inherits:
Error
  • Object
show all
Defined in:
lib/cuprum/collections/errors/failed_validation.rb

Overview

Error returned when a collection item fails validation.

Constant Summary collapse

TYPE =

Short string used to identify the type of error.

'cuprum.collections.errors.failed_validation'

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(entity_class:, errors:) ⇒ FailedValidation

Returns a new instance of FailedValidation.

Parameters:

  • entity_class (Class)

    The class of the assigned entity.

  • errors (Stannum::Errors)

    The errors generated when validating the entity.



16
17
18
19
20
21
22
23
24
25
# File 'lib/cuprum/collections/errors/failed_validation.rb', line 16

def initialize(entity_class:, errors:)
  @entity_class = entity_class
  @errors       = errors

  super(
    entity_class: entity_class,
    errors:       errors,
    message:      default_message
  )
end

Instance Attribute Details

#entity_classClass (readonly)

Returns the class of the assigned entity.

Returns:

  • (Class)

    the class of the assigned entity.



28
29
30
# File 'lib/cuprum/collections/errors/failed_validation.rb', line 28

def entity_class
  @entity_class
end

#errorsStannum::Errors (readonly)

Returns The errors generated when validating the entity.

Returns:

  • (Stannum::Errors)

    The errors generated when validating the entity.



31
32
33
# File 'lib/cuprum/collections/errors/failed_validation.rb', line 31

def errors
  @errors
end