On 9/11/07, Amit Upadhyay <[EMAIL PROTECTED]> wrote:
> On 9/10/07, Nis Jørgensen <[EMAIL PROTECTED]> wrote:
>
> > I don't like the transformation of strings into field values. How would
> > you compare a field value to a string?
>
> Exactly my reason for not making it a method of BaseForm. If things were
> simple and all validations were such that transfomation of strings into
> field value was enough, we would have gotten rid of one or more "
> self.clean_data" per statement for one extra "self.". Let me talk in code:
>
> If for some legacy reason, password is supposed to be case in sensitive, we
> would want to do:
>
>  def clean_password2(self):
>     self.validate_equal(self.clean_data["password1"].lower(),
> self.clean_data["password2"].lower(), "Please make sure..")
>     return self.clean_data["password2"]

So, essentially you are advocating replacing:

if self.clean_data['password2'].lower() != self.clean_data['password1'].lower():
    raise ValidationError("Please make sure"...")

with:

self.validate_equal(self.clean_data["password1"].lower(),
    self.clean_data["password2"].lower(),
    "Please make sure..")

I'm afraid you're going to have a hard time convincing me that this is
a good idea. I'm willing to entertain the idea of validation helpers
if they genuinely add clarity - but not if they are just a verbose
replacement for something that Python can already express quite
cleanly.

Yours,
Russ Magee %-)

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-developers?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to