Class: BraintreeRails::CustomerValidator
- Inherits:
-
Validator
- Object
- ActiveModel::Validator
- Validator
- BraintreeRails::CustomerValidator
show all
- Defined in:
- lib/braintree_rails/customer_validator.rb
Constant Summary
collapse
- Validations =
[
[:id, :format => {:with => /\A[-_a-z0-9]*\z/i}, :length => {:maximum => 36}, :exclusion => {:in => %w(all new)}],
[:first_name, :last_name, :company, :website, :phone, :fax, :length => {:maximum => 255}]
Instance Method Summary
collapse
Methods inherited from Validator
collect_validations, default_validations, model_class, reset_validations, set_validations, setup, #setup
Instance Method Details
#validate(customer) ⇒ Object
8
9
10
|
# File 'lib/braintree_rails/customer_validator.rb', line 8
def validate(customer)
validate_credit_card(customer) if customer.credit_card.present?
end
|
#validate_credit_card(customer) ⇒ Object
12
13
14
15
16
17
18
19
20
21
|
# File 'lib/braintree_rails/customer_validator.rb', line 12
def validate_credit_card(customer)
customer.instance_eval do
if credit_card.invalid?
errors.add(:credit_card, "is invalid")
credit_card.errors.full_messages.each do |message|
errors.add(:base, message)
end
end
end
end
|