class Reorm::MaximumLengthValidator
Public Class Methods
new(length, *field)
click to toggle source
Calls superclass method
# File lib/reorm/validators/maximum_length_validator.rb, line 7 def initialize(length, *field) super("is too long (maximum length is #{length} characters).", *field) @length = length end
Public Instance Methods
validate(object)
click to toggle source
# File lib/reorm/validators/maximum_length_validator.rb, line 12 def validate(object) value = field.value(object) if value && value.to_s.length > @length object.errors.add field.to_s, message end end