class PayCertify::Gateway::Customer::Validation

Constants

ALLOWED_STATUSES
ALLOWED_TYPES
ALL_VALIDATIONS

Public Class Methods

new(attributes={}) click to toggle source
# File lib/paycertify/gateway/customer.rb, line 43
def initialize(attributes={})
  super(attributes)

  ALL_VALIDATIONS.each do |attribute|
    presence_validation(attribute) if attribute[:required]
    send(attribute[:validation], attribute) if value_for(attribute).present?
  end
end

Public Instance Methods

type_validation(attribute) click to toggle source
# File lib/paycertify/gateway/customer.rb, line 52
def type_validation(attribute)
  unless value_for(attribute).try(:to_s).in?(ALLOWED_TYPES)
    add_error(attribute, "Must be one of #{ALLOWED_TYPES.join(', ')}")
  end
end