I have a simple schema structure as follows (unimportant parts removed
for brevity):
class RegistrationSchema1(schemaish.Structure):
""" Registration Schema Class """
password = schemaish.String(
validator=validatish.Length(min=6, max=10, messages={
'between': "Your
password must contain between %(min)s and %(max)s %(unit)s.",
'fewer-than':
"Your password must contain between %(min)s and %(max)s %(unit)s.",
'more-than': "Your
password must contain between %(min)s and %(max)s %(unit)s."}))
confirmpassword = schemaish.String(
validator=validatish.Equal("",
messages={'incorrect':'Passwords do not match.'}))
The issue is that I can't validate the confirmpassword field as the
value to compare to is supplied on object initialisation.
So I alter the class into the following form:
class RegistrationSchema(schemaish.Structure):
""" Registration Schema Class """
def __init__(self, password_confirm):
self.password = schemaish.String(
validator=validatish.Length(min=6, max=10, messages={
'between':
"Your password must contain between %(min)s and %(max)s %(unit)s.",
'fewer-than':
"Your password must contain between %(min)s and %(max)s %(unit)s.",
'more-than':
"Your password must contain between %(min)s and %(max)s %(unit)s."}))
self.confirmpassword = schemaish.String(
validator=validatish.Equal(password_confirm,
messages={'incorrect':'Passwords do not match.'}))
Now I can pass the value to compare with through the constructor.
Unfortunately when I do this, the validate method always passes
without raising Invalid exceptions when it is suppose to.
I am new to python and don't quite understand the difference between
the classes (my understanding is that as most entities are objects
it would seem to the equivalent).
How do others handle the Equal validator within a class?
My apologies about the python specific question,
Thanks
Burak