Hi,
I'm working on a web2py project, and I'm slowly learning. Thanks for all the ressources available. I needed a new DAL validator like IS_UPPER() but based on title(), so I looked over the source files and saw validators.py. I added the class IS_TITLE() to it but it doesn't seems to be enough to make it work on my model. Candid developer... What should I do ?
I'd like to contribute to the validators.py file, so here's a new class to add if web2py's team agree :
class IS_TITLE(Validator):
"""
Converts to title ::
>>> IS_TITLE()('abc-def ghi')
('Abc-Def Ghi', None)
>>> IS_TITLE()('é')
('\xc3\x89', None)
"""
def __call__(self, value):
return (value.decode('utf8').title().encode('utf8'), None)
And here's the documentation for the book :
IS_TITLE
This validator never returns an error. It converts the value to title case.
requires = IS_TITLE()