Numericality validation gets ignored. #49

konung opened this Issue Oct 25, 2012 · 3 comments

2 participants



Not sure if it should be considered a bug or a feature request but here we go:

Please consider this example:

monetize :core_charge_amount_cents, 
         :allow_nil => true, 
         :numericality => { :greater_than_or_equal_to => 0, 
                            :less_than_or_equal_to => 10000, 
                            :message => "Only amounts in the range 0 to $10000.00 are allowed or leave this value blank."  }

According to this line of code -
, it only allows for one option, and checks for numericality, but it doesn't allow to override that with some options. Right now I sidestep the issue but doing a custom validation via another method

validate :core_charge_amount_is_within_limits

but it seems to be it shouldn't be like that.


also , I know I can config.include_validation = false in initializing file, and define my own validations via

 validates_numericality_of :reman_amount_cents:allow_nil => true, :greater_than_or_equal_to => 0, :less_than_or_equal_to => 1000000, :message => "Only amounts in the range 0 to 10000.00 are allowed." 

, but it's seems to be counterintuitve to allow one validation (:allow_nil => true), but not the other. Plus there is a problem with this approach as all error messages get assigned to core_charge_amount_cents rather than virtual attribute core_charge_amount - therefore they won't be displayed on the view ( as simple_form in my case wouldn't know about this erros), however the form won't be submitted until the error is cleared.

( I'm displaying errors in line, not listing all my errors at the top)

RubyMoney member

@konung Can you provide a patch for this?

RubyMoney member

This has been addressed by #70

@alup alup closed this Jan 25, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment