Method: Modelish::Validations::ClassMethods#validate_length
- Defined in:
- lib/modelish/validations.rb
#validate_length(name, value, max_length) ⇒ Object
Validates the length of a value, returning an error when validation fails.
148 149 150 151 152 153 |
# File 'lib/modelish/validations.rb', line 148 def validate_length(name, value, max_length) if max_length.to_i > 0 && value.to_s.length > max_length.to_i = "#{name} must be less than #{max_length} characters" ArgumentError.new() end end |