Lee McFadden schrieb:
> chained_validators = [validators.FieldsMatch('password', 'password_2'),
> validators.FieldsMatch('email', 'email_2')]
>
> Note the chained_validators list. This will ensure that the field
> named 'password' matches the field named 'password_2' and will act
> like any other validation error.
Well, not exactly. The thing you have to remember with chained
validators is to set the error message dict yourself, otherwise the
validation error will show up next to _each_ field:
class MyCustomValidator(validators.FancyValidator):
messages = {
'foo': 'Foo made a boo boo"
}
def validate_python(self, value, state):
if not some_check(value):
message = self.message('notUnique2', state)
# are we called as a chained validator?
if isinstance(value, dict):
errors = dict(url=message)
raise validators.Invalid(message, value, state,
error_dict=errors)
raise validators.Invalid(message, value, state)
Chris
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"TurboGears" 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/turbogears?hl=en
-~----------~----~----~----~------~----~------~--~---