mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-02-05 02:42:26 -05:00
110067722: Add form validation for duplicate service name.
This commit is contained in:
@@ -5,7 +5,7 @@ from flask_wtf import Form
|
||||
from wtforms import StringField, PasswordField
|
||||
from wtforms.validators import DataRequired, Email, Length, Regexp
|
||||
|
||||
from app.main.dao import verify_codes_dao
|
||||
from app.main.dao import verify_codes_dao, services_dao
|
||||
from app.main.encryption import check_hash
|
||||
from app.main.validators import Blacklist
|
||||
|
||||
@@ -85,4 +85,11 @@ def validate_code(field, code):
|
||||
|
||||
|
||||
class AddServiceForm(Form):
|
||||
service_name = StringField(validators=[DataRequired(message='Name can not be empty')])
|
||||
service_name = StringField(validators=[DataRequired(message='Please enter your service name')])
|
||||
|
||||
def validate_service_name(self, a):
|
||||
if services_dao.find_service_by_service_name(self.service_name.data) is not None:
|
||||
self.service_name.errors.append('Duplicate service name')
|
||||
return False
|
||||
else:
|
||||
return True
|
||||
|
||||
Reference in New Issue
Block a user