Hi Vanessa, On Tue, Sep 9, 2008 at 8:40 AM, Bani <[EMAIL PROTECTED]> wrote: > > Hi, > > Can someone give me a hand on the validation of the credit card format > for the homework of the Active Record lesson? > It says: > # User can enter the credit card format in the following format. The > x has to be numeric value. > * xxxx-xxxx-xxxx-xxxx (format #1) > * xxxx xxxx xxxx xxxx (format #2) > * xxxxxxxxxxxxxxxx (format #3) > If someone could write the regex for it nicely that would be very helpful. > Well, you are asking us to do your homeworks? ;-)
On the web there are a lot of good example of regex expression that validates true credit card numbers and other stuffs, like this one: http://www.bluejazzconsulting.com/2006/04/23/validation-using-regular-expressions/ you have to adapt it to this particular specs and then using before_save and before_create to bring format #1 and #2 to the third one. BTW I've found that is important the order of the validations you use (if you validates first for uniqueness and than for correct format, same cc number in different format result as different...) Best regards Pietro --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "ruby-on-rails-programming-with-passion" group. To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/ruby-on-rails-programming-with-passion?hl=en?hl=en -~----------~----~----~----~------~----~------~--~---
