If you benefit from web2py hope you feel encouraged to pay it forward by contributing back to society in whatever form you choose!


  • 0
    rochacbruno  11 years ago

    Is it really needed to have the __init__ method? I did not tested, but, the init is doing nothing.

     

    requires=CLEANUP_JUST_NUMBERS() will create an object without the need to pass any argument.

    Also I never created a subclass of Validator. I always use just "object" and it works. There is some advantage on subclassing Validator?

     

    BTW: Thanks for the slice!

    replies (1)
    • viniciusban 11 years ago

      You're right. We don't need __init__(). Code updated. Thanks.

      I subclass Validator just because all Web2py native validators do this way.

Commented on:

Numeric fields, like zip code, usually has characters other than numbers when edited in a form. When they are submitted to backend, you need to sanitize them, ignoring non-numeric chars. This is what this validator makes. Put it inside a module and import it, or put inside your models dir and just use it.

Hosting graciously provided by:
Python Anywhere