Hi,

I have created a generic model class with a custom field validator to
which I have defined in the model as:
class MyModel(models.Model):
    snum = models.CharField(max_length=5, validator_list=[is_valid_snum])

The function `is_valid_snum` has been defined as a global function
outside class as:

def is_valid_snum(field_data, all_data):
    snum = str(field_data)
    if re.compile("^9(8|9|2|3|4)\d{3}").match(snum) is None:
        raise validators.ValidationError('Invalid format.'')
    return field_data

When I am trying to test this model from shell, it's just saving the
data without any error messages when it is invalid. I don't know whats
wrong in the code above. Any suggestions how can I fix this?

Thanks & regards,
BB

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@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-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to