Use Optional validator for BA code
This commit is contained in:
@@ -2,7 +2,7 @@ import re
|
|||||||
import pendulum
|
import pendulum
|
||||||
from wtforms.fields.html5 import DateField, EmailField
|
from wtforms.fields.html5 import DateField, EmailField
|
||||||
from wtforms.fields import StringField, FileField
|
from wtforms.fields import StringField, FileField
|
||||||
from wtforms.validators import InputRequired, Required, Email, Regexp
|
from wtforms.validators import InputRequired, Required, Optional, Email, Regexp
|
||||||
from flask_wtf.file import FileAllowed
|
from flask_wtf.file import FileAllowed
|
||||||
|
|
||||||
from atst.domain.exceptions import NotFoundError
|
from atst.domain.exceptions import NotFoundError
|
||||||
@@ -123,7 +123,7 @@ class BaseFinancialForm(ValidatedForm):
|
|||||||
ba_code = StringField(
|
ba_code = StringField(
|
||||||
"Program Budget Activity (BA) Code (Optional)",
|
"Program Budget Activity (BA) Code (Optional)",
|
||||||
description="BA Code is used to identify the purposes, projects, or types of activities financed by the appropriation fund. <br/><em>It should be two digits, followed by an optional letter.</em>",
|
description="BA Code is used to identify the purposes, projects, or types of activities financed by the appropriation fund. <br/><em>It should be two digits, followed by an optional letter.</em>",
|
||||||
validators=[Regexp(BA_CODE_REGEX)],
|
validators=[Optional(), Regexp(BA_CODE_REGEX)],
|
||||||
)
|
)
|
||||||
|
|
||||||
fname_co = StringField("KO First Name", validators=[Required()])
|
fname_co = StringField("KO First Name", validators=[Required()])
|
||||||
|
@@ -74,8 +74,8 @@ def test_treasury_code_validation(input_, expected):
|
|||||||
],
|
],
|
||||||
)
|
)
|
||||||
def test_ba_code_validation(input_, expected):
|
def test_ba_code_validation(input_, expected):
|
||||||
form_data = {"ba_code": input_}
|
form_data = ImmutableMultiDict([("ba_code", input_)])
|
||||||
form = FinancialForm(data=form_data)
|
form = FinancialForm(form_data)
|
||||||
form.validate()
|
form.validate()
|
||||||
is_valid = "ba_code" not in form.errors
|
is_valid = "ba_code" not in form.errors
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user