diff options
author | Niels Ganser <niels@herimedia.com> | 2012-02-06 12:56:38 +0100 |
---|---|---|
committer | Niels Ganser <niels@herimedia.com> | 2012-02-06 12:58:32 +0100 |
commit | 60dad828aefa41703c0eee3863a7141c56caa7da (patch) | |
tree | cce2fbfd0eb84e92758f83cc847d287bd7792d02 /activemodel/lib/active_model/validations | |
parent | af7dafff818094a6e02505fe7d6d87add6c2a7e8 (diff) | |
download | rails-60dad828aefa41703c0eee3863a7141c56caa7da.tar.gz rails-60dad828aefa41703c0eee3863a7141c56caa7da.tar.bz2 rails-60dad828aefa41703c0eee3863a7141c56caa7da.zip |
To infinity… and beyond!
Allow infinite values for validates_length_of. Particularly useful
for prettily defining an open ended range such as
validates_length_of :human_stupidity, :within => 0..Float::INFINITY
Diffstat (limited to 'activemodel/lib/active_model/validations')
-rw-r--r-- | activemodel/lib/active_model/validations/length.rb | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/activemodel/lib/active_model/validations/length.rb b/activemodel/lib/active_model/validations/length.rb index 0eba241333..0bbd81a984 100644 --- a/activemodel/lib/active_model/validations/length.rb +++ b/activemodel/lib/active_model/validations/length.rb @@ -29,8 +29,8 @@ module ActiveModel keys.each do |key| value = options[key] - unless value.is_a?(Integer) && value >= 0 - raise ArgumentError, ":#{key} must be a nonnegative Integer" + unless value.is_a?(Integer) && value >= 0 or value == Float::INFINITY + raise ArgumentError, ":#{key} must be a nonnegative Integer or Infinity" end end end |