Hi!
I plan to use ActiveModel::Validator to validate a plain Ruby class, but
I have intention to keep all validations outside the original class,
while using PresenceValidator and FormatValidator, default on Rails.
Something like this:
payer.rb
module MyMoip
class Payer
include ActiveModel::Validations
attr_accessor :id, :name, :email,
:address_street, :address_street_number,
:address_street_extra,
:address_neighbourhood, :address_city, :address_state,
:address_country, :address_cep, :address_phone
validates_with Validators::PayerValidator
end
end
payer_validator.rb
module MyMoip
module Validators
class PayerValidator < ActiveModel::Validator
validate :id, presence: true
def validate(record)
# more complex validations
end
end
end
end
It is possible?