Exception: Eddy::Errors::LengthValidationError

Inherits:
ElementValidationError show all
Defined in:
lib/eddy/errors.rb

Overview

Exception raised when an invalid argument is passed to the value= method of an Models::Element::Base class.

Instance Attribute Summary

Attributes inherited from ElementValidationError

#arg, #element

Element Validation Errors collapse

Methods inherited from ElementValidationError

#element_description

Constructor Details

#initialize(msg = "", element:, arg:) ⇒ void

Parameters:

  • element (Eddy::Models::Element::Base)

    Element instance that raised the exception.

  • arg (Object)

    Passed argument that caused the exception.

  • msg (String) (defaults to: "")

    ("")



91
92
93
94
95
96
97
98
99
# File 'lib/eddy/errors.rb', line 91

def initialize(msg = "", element:, arg:)
  self.element = element
  self.arg = arg
  if msg.length == 0
    msg << "Value can't be longer than #{self.element.max}. "
    msg << "Length of recieved value: #{self.arg.to_s.length}"
  end
  super(msg)
end