Class: FormKeeper::Constraint::ByteSize

Inherits:
Base
  • Object
show all
Defined in:
lib/formkeeper.rb

Instance Method Summary collapse

Instance Method Details

#validate(value, arg) ⇒ Object



297
298
299
300
301
302
303
304
305
306
307
# File 'lib/formkeeper.rb', line 297

def validate(value, arg)
  l = value.bytesize
  case arg
  when Fixnum
    return (l == arg)
  when Range
    return arg.include?(l)
  else
    raise ArgumentError.new('Invalid number of arguments')
  end
end