Skip to content

Instantly share code, notes, and snippets.

@fidel
Created October 11, 2011 11:28
Show Gist options
  • Save fidel/1277861 to your computer and use it in GitHub Desktop.
Save fidel/1277861 to your computer and use it in GitHub Desktop.
CC validation
module Validations
class Validations::ExpiryMonthValidator < ActiveModel::EachValidator
include ActiveMerchant::Billing::CreditCardMethods
def validate_each(record, attribute, value)
record.errors[attribute] << 'is not a valid month' unless record.valid_month?(value)
end
end
end
ActiveModel::Validations::ExpiryMonthValidator = Validations::ExpiryMonthValidator
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment