Fixed a double error bug

This commit is contained in:
xemeds
2020-07-19 22:14:49 +00:00
parent c229f4e0c3
commit 0db137daf5
2 changed files with 3 additions and 4 deletions
+2 -3
View File
@@ -6,8 +6,7 @@ from wtforms.validators import DataRequired, Length
def validate_URL(form, field):
# Make sure the url is not too short or long
if len(field.data) < 4 or len(field.data) > 2000:
# Raise a ValidationError
raise ValidationError()
return
# If the url contains spaces or does not have any dots
if field.data.count(" ") > 0 or field.data.count(".") == 0:
@@ -32,7 +31,7 @@ def validate_URL(form, field):
class URLForm(FlaskForm):
url = StringField(validators=[DataRequired(),
Length(min=4, max=2000, message="URL must be between %(min)d and %(max)d characters"),
Length(min=4, max=2000, message="Invalid URL Length"),
validate_URL])
submit = SubmitField("Shorten")