max-power / iban

This repository moved to max-power/bank
https://github.com/max-power/bank
MIT License
6 stars 3 forks source link

Fix “undefined method `strip' for nil:NilClass” in ActiveModel validator #1

Closed maser closed 10 years ago

maser commented 10 years ago

If the attribute value is nil, validation fails with a NoMethodError. As the IBAN attribute might be optional in the model where the validation is used, I changed it to allow nil as a value instead of adding an error.

To validate presence, the user can still do validates presence: true, iban: true

maser commented 10 years ago

Sorry, I should have read the Rails docs more carefully!

maser commented 10 years ago

@max-power The exception still happens though when the attribute is nil. There should be a validation error instead of an exception when the value is nil.

max-power commented 10 years ago

alright, with commit 8549dceca7392c9fc573b61fbc39676974d32909 the value you pass will be converted to a string first. please try it and give feedback.

maser commented 10 years ago

Perfect! Thanks for your work on this gem, it saved me a lot of time.

max-power commented 10 years ago

you are very welcome.