Create yor own validation helper

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

What do you want it to do?

On Feb 20, 2008 11:00 AM, Julius C.
[email protected]
wrote:


Ryan B.

Feel free to add me to MSN and/or GTalk as this email.

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

On Feb 19, 4:41 pm, Julius C. [email protected]