python - How to do simple value check with error message in Deform/Colander -


i'm implementing simple 'tick agree terms , conditions box' in deform/colander.

so, want check box checked , have error message saying 'you must agree t&c'.

i understand can use:

colander.oneof([true])  

to ensure box ticked. however, oneof not allow custom error message. correct way be?

use custom validator:

def t_and_c_validator(node, value):     if not value:         raise invalid(node, 'you must agree t&c')  class myschema(colander.schema):     t_and_c = colander.schemanode(                   colander.boolean(),                   description='terms , conditions',                   widget=deform.widget.checkboxwidget(),                   title='terms , conditions',                   validator=t_and_c_validator,                   ) 

Comments

Popular posts from this blog

linux - Using a Cron Job to check if my mod_wsgi / apache server is running and restart -

actionscript 3 - TweenLite does not work with object -

jQuery Ajax Render Fragments OR Whole Page -