Hi there! Does anyone know if it's possible to create your own customized validation helper? If yes, how do I do that?
cheers guys julius
Hi there! Does anyone know if it's possible to create your own customized validation helper? If yes, how do I do that?
cheers guys julius
Well, my validation is checking some input, so tat it has only 2 decimals. I use validate_format_of and validate_numericality_of. Now, what I wanted to do is, combine both in one customized helper (validate_2_decimals_of for example)because I'm using those methods quite often. just to make it easy to maintain and stuff.. Any idea?
You can extend the default Rails validations through Ruby's great extensions capability. Just create a file (my_validations.rb) in your project's lib folder and then in environment.rb add: require 'my_validations'.
module ActiveRecord module Validations module ClassMethods
def validates_2_decimals_of # ... end
end end end
Jason Arora