Class: Cure::Validator::LengthRule
Instance Method Summary
collapse
Methods inherited from BaseRule
#initialize
Instance Method Details
#max ⇒ Object
57
58
59
|
# File 'lib/cure/validator/base_rule.rb', line 57
def max
@max || @options.fetch(:max, 99_999)
end
|
#min ⇒ Object
53
54
55
|
# File 'lib/cure/validator/base_rule.rb', line 53
def min
@min || @options.fetch(:max, 0)
end
|
#process(value) ⇒ Object
41
42
43
44
45
46
47
|
# File 'lib/cure/validator/base_rule.rb', line 41
def process(value)
return true if value.nil?
return true unless value.respond_to? :size
length = value.size
length >= min && length <= max
end
|
#to_s ⇒ Object
49
50
51
|
# File 'lib/cure/validator/base_rule.rb', line 49
def to_s
"Length [Min: #{min}, Max: #{max}]"
end
|