Implement regex validation with WTForms and python

Viewed 13

So, here is my code and where I'm at:

class CommentsForm( FlaskForm):
    comment = TextAreaField('New Comment', render_kw={'placeholder': 'What do you have to say?'}, [validators.regex("^[A-Za-z0-9_-]*$", flags=0, message=u'Comments can only include letters and numbers.')])
    submit = SubmitField('Comment')

So the goal is to validate the input field (preferably with an regex) just so that it creates an additional barrier for injection style attacks. Tried finding my explenation here: http://wtforms.simplecodes.com/docs/0.6/validators.html but validators.regex is not defined i dont get it running. Thanks

0 Answers
Related