Browse Source

added optional length requirement (if entered, length has to be >2 <51)

Casper Van Gheluwe 11 years ago
parent
commit
c8a2cf331c
1 changed files with 2 additions and 2 deletions
  1. 2 2
      flaskbb/forum/forms.py

+ 2 - 2
flaskbb/forum/forms.py

@@ -11,7 +11,7 @@
 from flask.ext.wtf import Form
 from flask.ext.wtf import Form
 import flask.ext.whooshalchemy
 import flask.ext.whooshalchemy
 from wtforms import TextAreaField, TextField, BooleanField, FormField, SelectMultipleField
 from wtforms import TextAreaField, TextField, BooleanField, FormField, SelectMultipleField
-from wtforms.validators import Required
+from wtforms.validators import Required, Optional, Length
 
 
 from flaskbb.forum.models import Topic, Post, Report, Forum, Category
 from flaskbb.forum.models import Topic, Post, Report, Forum, Category
 from flaskbb.user.models import User
 from flaskbb.user.models import User
@@ -64,7 +64,7 @@ class SearchForm(Form):
         super(SearchForm, self).__init__()
         super(SearchForm, self).__init__()
         self.search_types = search_types
         self.search_types = search_types
 
 
-    search_query = TextField("Search Query")
+    search_query = TextField("Search", validators=[Optional(), Length(min=3, max=50)])
 
 
     def get_types(self):
     def get_types(self):
         return self.search_types
         return self.search_types