From 8802b03a13cffb215d206b323042d9dffc328158 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Roland=20H=C3=A4der?= Date: Sun, 25 Sep 2022 22:36:04 +0200 Subject: [PATCH] Please cherry-pick: - branch offices have optional email addresses (finally found the bug that you always must enter an email address while the form field is not marked as required) --- .../JobsHeadquarterCompanyNameValidator.java | 4 ++-- ...JobsBranchOfficeEmailAddressValidator.java | 22 ++----------------- 2 files changed, 4 insertions(+), 22 deletions(-) diff --git a/src/java/org/mxchange/jjobs/validator/business/headquarter/JobsHeadquarterCompanyNameValidator.java b/src/java/org/mxchange/jjobs/validator/business/headquarter/JobsHeadquarterCompanyNameValidator.java index 971b916e..c4828b3c 100644 --- a/src/java/org/mxchange/jjobs/validator/business/headquarter/JobsHeadquarterCompanyNameValidator.java +++ b/src/java/org/mxchange/jjobs/validator/business/headquarter/JobsHeadquarterCompanyNameValidator.java @@ -51,7 +51,7 @@ public class JobsHeadquarterCompanyNameValidator extends BaseStringValidator { final String[] requiredFields = {"companyName"}; //NOI18N // Pre-validation (example: not null, not a string, empty string ...) - super.preValidate(context, component, value, requiredFields, false); + super.preValidate(context, component, value, requiredFields, Boolean.FALSE); // Convert name to string (now securely checked in BaseStringValidator) final String companyName = (String) value; @@ -59,7 +59,7 @@ public class JobsHeadquarterCompanyNameValidator extends BaseStringValidator { // Default is to check on existing names Boolean checkExisting = Boolean.TRUE; - // Is attribute "allowEmptyRequiredData" set? + // Is attribute "checkExisting" set? if (component.getAttributes().containsKey("checkExisting")) { //NOI18N // Get attribute final Object attribute = component.getAttributes().get("checkExisting"); //NOI18N diff --git a/src/java/org/mxchange/jjobs/validator/emailaddress/branchoffice/JobsBranchOfficeEmailAddressValidator.java b/src/java/org/mxchange/jjobs/validator/emailaddress/branchoffice/JobsBranchOfficeEmailAddressValidator.java index 2baba45e..f9c911a6 100644 --- a/src/java/org/mxchange/jjobs/validator/emailaddress/branchoffice/JobsBranchOfficeEmailAddressValidator.java +++ b/src/java/org/mxchange/jjobs/validator/emailaddress/branchoffice/JobsBranchOfficeEmailAddressValidator.java @@ -56,25 +56,10 @@ public class JobsBranchOfficeEmailAddressValidator extends BaseStringValidator { */ private static final long serialVersionUID = 187_536_745_607_196L; - /** - * Whether empty data is allowed - */ - private Boolean allowEmptyRequiredData; - /** * Default constructor */ public FinancialsBranchOfficeEmailAddressValidator () { - this.allowEmptyRequiredData = Boolean.FALSE; - } - - /** - * Setter for allowEmptyRequiredData flag - *

- * @param allowEmptyRequiredData Whether empty values are allowed - */ - public void setAllowEmptyRequiredData (final Boolean allowEmptyRequiredData) { - this.allowEmptyRequiredData = allowEmptyRequiredData; } @Override @@ -83,15 +68,12 @@ public class JobsBranchOfficeEmailAddressValidator extends BaseStringValidator { final String[] requiredFields = {"branchEmailAddress"}; //NOI18N // Pre-validation (example: not null, not a string, empty string ...) - super.preValidate(context, component, value, requiredFields, this.allowEmptyRequiredData); + super.preValidate(context, component, value, requiredFields, Boolean.TRUE); // Is the email address empty and allowed? - if (null == value && this.allowEmptyRequiredData) { + if (null == value) { // Then accept this here return; - } else if (null == value) { - // Abort here - throw new ValidatorException(new FacesMessage("No empty email address allowed.")); //NOI18N } // Get string from object ... ;-) -- 2.39.5