class AttrStatements::Validations::Length

Constants

ERROR_TYPES

Private Instance Methods

maximum(max, value) click to toggle source

:reek: UtilityFunction (because of metaprogramming)

# File lib/attr_statements/validations/length.rb, line 30
def maximum(max, value)
  max.is_a?(Integer) && value.is_a?(String) && value.size > max
end
options(value) click to toggle source
# File lib/attr_statements/validations/length.rb, line 25
def options(value)
  { count: value }
end
validate_each(value) click to toggle source
# File lib/attr_statements/validations/length.rb, line 11
def validate_each(value)
  type_errors = []

  ERROR_TYPES.each do |check_key, error_message|
    check_value = statement.length[check_key]

    if __send__(check_key, check_value, value)
      type_errors << Error.new(error_message, options(check_value))
    end
  end

  type_errors
end