Sha256: d9744c110c4d282cff6461318554b3091527389be52b1f4f1b8b1788e698e321
Contents?: true
Size: 690 Bytes
Versions: 13
Compression:
Stored size: 690 Bytes
Contents
module Ohm module LengthValidations 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 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 private def is_too_long?(string, length) string.size <= length rescue ArgumentError return false end def is_long_enough?(string, length) string.size >= length rescue ArgumentError return false end end end
Version data entries
13 entries across 13 versions & 1 rubygems