Class: LIVR::Rules::String::MinLength
- Inherits:
-
LIVR::Rule
- Object
- LIVR::Rule
- LIVR::Rules::String::MinLength
- Defined in:
- lib/livr/rules/string.rb
Instance Method Summary collapse
- #call(value, user_data, field_results) ⇒ Object
-
#initialize(min_length) ⇒ MinLength
constructor
A new instance of MinLength.
Constructor Details
#initialize(min_length) ⇒ MinLength
Returns a new instance of MinLength.
70 71 72 |
# File 'lib/livr/rules/string.rb', line 70 def initialize(min_length) @min_length = min_length end |
Instance Method Details
#call(value, user_data, field_results) ⇒ Object
74 75 76 77 78 79 80 81 82 83 |
# File 'lib/livr/rules/string.rb', line 74 def call(value, user_data, field_results) return if is_no_value(value) return 'FORMAT_ERROR' unless is_primitive(value) if value.to_s.length < @min_length return 'TOO_SHORT' end field_results << value.to_s return end |