(sorry for the double-post. i only later realized that replying to a 
previous thread is not a good idea)

hi,

i tried to implement the validation-logic for some of the fields, but
while looking at the source code, i found this inconsistency...

question:

========================
class SlugField(Field):
     def __init__(self, *args, **kwargs):
         kwargs['maxlength'] = kwargs.get('maxlength', 50)
         kwargs.setdefault('validator_list', []).append(validators.isSlug)
         # Set db_index=True unless it's been set manually.
         if not kwargs.has_key('db_index'):
             kwargs['db_index'] = True
         Field.__init__(self, *args, **kwargs)
=======================

as you see, it sets up the validators.isSlug validator

=======================
class EmailField(CharField):
     def __init__(self, *args, **kwargs):
         kwargs['maxlength'] = 75
         CharField.__init__(self, *args, **kwargs)
<snip/>
     def validate(self, field_data, all_data):
         validators.isValidEmail(field_data, all_data)
========================

this one does not set up a validator, and does a "manual" validation.


why do they behave differently?

or, better question:

what's the recommended approach:
add validators to the field's validator_list, or remove those and do an
explicit validation in the validate() method?

gabor


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

Reply via email to