class LIVR::Rules::String::LengthBetween
Public Class Methods
new(min_length, max_length)
click to toggle source
# File lib/livr/rules/string.rb, line 106 def initialize(min_length, max_length) @min_length = min_length @max_length = max_length end
Public Instance Methods
call(value, user_data, field_results)
click to toggle source
# File lib/livr/rules/string.rb, line 111 def call(value, user_data, field_results) return if value.in? [nil, ""] return 'FORMAT_ERROR' unless is_primitive(value) value = value.to_s return 'TOO_SHORT' if value.length < @min_length return 'TOO_LONG' if value.length > @max_length field_results << value return end