Validation order

Hi,

Say I have this:

class Order < AR
validates_presence_of :credit_card_number
validates_presence_of :credit_card_expiry_date
validate :credit_card_is_good?
validate_format … # regex for credit card
validate_format … # regex for expiration date
private
validate credit_card_is_good?
# Use the number and expiry date to check against a remote service
# to see if the card is any good or not
end
end

Now, in order to run Order::credit_card_is_good?, I need to be sure
that the user has entered in a valid credit card number and expiration
date. But, credit_card_is_good? seems to run before the other
validations do. Do I want to use after_validate or something for that
function?

Thanks,
Joe

On 9/6/06, [email protected] [email protected] wrote:

validate_format … # regex for expiration date
validations do. Do I want to use after_validate or something for that
function?

Thanks,
Joe

Have you tried placing the “validate:credit_card_is_good” line last,
after all the other validations in you class?