Skip to content

Commit

Permalink
Accept allow_blank for numericality validations since it's a valid op…
Browse files Browse the repository at this point in the history
…tion.
  • Loading branch information
jarkko committed Oct 18, 2012
1 parent f815156 commit 7883d58
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
2 changes: 1 addition & 1 deletion lib/client_side_validations/active_model/numericality.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ def client_side_hash(model, attribute, force = nil)
hash[:only_integer] = true
end

hash[:allow_blank] = true if options[:allow_nil]
hash[:allow_blank] = true if options[:allow_nil] || options[:allow_blank]

OPTION_MAP.each do |option, message_type|
if count = options[option]
Expand Down
3 changes: 2 additions & 1 deletion test/active_model/cases/test_validations.rb
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ def test_validations_to_client_side_hash_with_validations_on_create
p.validates_length_of :last_name, :is => 10, :on => :update
p.validates_format_of :first_name, :with => //, :on => :update
p.validates_format_of :last_name, :with => //, :on => :create
p.validates_numericality_of :age, :on => :create
p.validates_numericality_of :age, :on => :create, :allow_blank => true
p.validates_numericality_of :weight, :on => :update
p.class_eval do
def new_record?
Expand All @@ -87,6 +87,7 @@ def new_record?
:age => {
:numericality => [{
:messages => { :numericality => 'is not a number' },
:allow_blank => true
}]
}
}
Expand Down

0 comments on commit 7883d58

Please sign in to comment.