Module: Ohm::LengthValidations

Included in:
ExtraValidations
Defined in:
lib/ohm/contrib/length_validations.rb

Instance Method Summary collapse

Instance Method Details

#assert_max_length(att, length, error = [att, :too_long]) ⇒ Object



11
12
13
14
15
16
# File 'lib/ohm/contrib/length_validations.rb', line 11

def assert_max_length(att, length, error = [att, :too_long])
  if assert_present(att, error)
    m = send(att).to_s
    assert is_too_long?(m, length), error
  end
end

#assert_min_length(att, length, error = [att, :too_short]) ⇒ Object



4
5
6
7
8
9
# File 'lib/ohm/contrib/length_validations.rb', line 4

def assert_min_length(att, length, error = [att, :too_short])
  if assert_present(att, error)
    m = send(att).to_s
    assert is_long_enough?(m, length), error
  end
end