Revised the IsDebitAccount and IsCreditAccount validators to require the error message, and moved their default error messages to the DebitLineItemForm and CreditLineItemForm forms.

This commit is contained in:
2023-03-22 23:19:52 +08:00
parent 7ccc96bda0
commit 35e05b3708
2 changed files with 20 additions and 22 deletions

View File

@ -53,14 +53,11 @@ class AccountExists:
class IsDebitAccount:
"""The validator to check if the account is for debit line items."""
def __init__(self, message: str | LazyString | None = None):
def __init__(self, message: str | LazyString):
"""Constructs the validator.
:param message: The optional custom error message.
:param message: The error message.
"""
if message is None:
message = lazy_gettext(
"This account is not for debit line items.")
self.__message: str | LazyString = message
def __call__(self, form: FlaskForm, field: StringField) -> None:
@ -76,14 +73,11 @@ class IsDebitAccount:
class IsCreditAccount:
"""The validator to check if the account is for credit line items."""
def __init__(self, message: str | LazyString | None = None):
def __init__(self, message: str | LazyString):
"""Constructs the validator.
:param message: The optional custom error message.
:param message: The error message.
"""
if message is None:
message = lazy_gettext(
"This account is not for credit line items.")
self.__message: str | LazyString = message
def __call__(self, form: FlaskForm, field: StringField) -> None: