Exception: UseCasePattern::ValidationError

Inherits:
StandardError
  • Object
show all
Defined in:
lib/use_case_pattern/base.rb

Overview

Use Case Pattern ValidationError

Raised by perform! when validations result in errors.

Check the use case errors object for attribute error messages.

ActiveModel 5.0 has an ActiveModel::ValidationError class, prior versions including 4.2 do not.

This class may be deprecated by ActiveModel::ValidationError in the future.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(model) ⇒ ValidationError

Returns a new instance of ValidationError.



62
63
64
65
66
# File 'lib/use_case_pattern/base.rb', line 62

def initialize(model)
  @model = model
  errors = @model.errors.full_messages.join(", ")
  super("Validation failed: " + errors)
end

Instance Attribute Details

#modelObject (readonly)

Returns the value of attribute model.



60
61
62
# File 'lib/use_case_pattern/base.rb', line 60

def model
  @model
end