> At first I thought it would not matter if we normalized an unacceptable
card, and then I remembered that .. it would be strange if the format
changed.

This is not a question of whether *it would be strange or not*. The
Requirements specify that *the card* *must have one of 3 formats*. So, it is
not debatable.

> If everything is ok, we normalize the data, otherwise we let it be and the
validation will fail in...

Excellent

> So just use before_validation and *not *before_save at all

Exactly. That's our goodbye to Escher's castle,

Raul


On Sun, Nov 2, 2008 at 6:30 PM, anne001 <[EMAIL PROTECTED]> wrote:

>
> c) however, we must normalize it only if it is an acceptable credit
> card...
> (else we would be accepting any assortment of digits and spaces).
>
> At first I thought it would not matter if we normalized an
> unacceptable card, and then I remembered that often we fill in the
> form with what the user entered, and it would be strange if the format
> changed. So I agree, the format should not be normalized unless it is
> an acceptable credit card.
>
> So we use before_validation, we start with our own format validation
> with a regular expression.
> If everything is ok, we normalize the data, otherwise we let it be and
> the validation will fail in
> format validation.
>
> So just use before_validation and not use before_create or before_save
> at all.
> >
>

--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to