Method: Sequel::Plugins::ValidationHelpers::InstanceMethods#validates_max_length
- Defined in:
- lib/sequel/plugins/validation_helpers.rb
#validates_max_length(max, atts, opts = OPTS) ⇒ Object
Check that the attribute values are not longer than the given max length.
Accepts a :nil_message option that is the error message to use when the value is nil instead of being too long.
140 141 142 143 144 145 146 147 148 |
# File 'lib/sequel/plugins/validation_helpers.rb', line 140 def validates_max_length(max, atts, opts=OPTS) validatable_attributes_for_type(:max_length, atts, opts) do |a,v,m| if v.nil? (opts[:nil_message] || (:max_length)[:nil_message]) elsif v.length > max (m, max) end end end |