validators icon indicating copy to clipboard operation
validators copied to clipboard

Using validators without class method

Open marcoschicote opened this issue 3 years ago • 0 comments

Hi I was wondering if it was possible to use the validators without using the class method. Instead of doing something like this:

class Server < ActiveRecord::Base
  validates_ip_address :address
end

I would like to write something like this:

class Server < ActiveRecord::Base
  validate :address, using: IpAddressValidator
end

Thanks!

marcoschicote avatar Apr 30 '21 14:04 marcoschicote