From a55538134ffeabea67fc1e0adb56cd32b48ccb41 Mon Sep 17 00:00:00 2001 From: Anusha Sunkada Date: Mon, 8 Jan 2024 20:06:57 +0530 Subject: [PATCH] ES-391 fixed validation issue (#84) Signed-off-by: ase-101 Signed-off-by: Sreang Rathanak --- .../src/main/java/io/mosip/signup/dto/UserInfoMap.java | 3 ++- .../io/mosip/signup/validator/LanguageValueValidator.java | 4 +++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/signup-service/src/main/java/io/mosip/signup/dto/UserInfoMap.java b/signup-service/src/main/java/io/mosip/signup/dto/UserInfoMap.java index e72e202d..b99b077f 100644 --- a/signup-service/src/main/java/io/mosip/signup/dto/UserInfoMap.java +++ b/signup-service/src/main/java/io/mosip/signup/dto/UserInfoMap.java @@ -6,6 +6,7 @@ import io.mosip.signup.validator.Language; import lombok.Data; +import javax.validation.Valid; import javax.validation.constraints.NotEmpty; import java.util.List; @@ -16,7 +17,7 @@ public class UserInfoMap { private String phone; @NotEmpty(message = ErrorConstants.INVALID_FULLNAME) - private List<@LanguageValue(valuePatternKey = "mosip.signup.fullname.pattern") + private List<@Valid @LanguageValue(valuePatternKey = "mosip.signup.fullname.pattern") LanguageTaggedValue> fullName; @Language diff --git a/signup-service/src/main/java/io/mosip/signup/validator/LanguageValueValidator.java b/signup-service/src/main/java/io/mosip/signup/validator/LanguageValueValidator.java index 21d17fd2..a9cd7dd3 100644 --- a/signup-service/src/main/java/io/mosip/signup/validator/LanguageValueValidator.java +++ b/signup-service/src/main/java/io/mosip/signup/validator/LanguageValueValidator.java @@ -3,6 +3,7 @@ import io.mosip.signup.dto.LanguageTaggedValue; import org.springframework.core.env.Environment; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.util.StringUtils; import javax.validation.ConstraintValidator; import javax.validation.ConstraintValidatorContext; @@ -25,6 +26,7 @@ public void initialize(LanguageValue value) { public boolean isValid(LanguageTaggedValue value, ConstraintValidatorContext constraintValidatorContext) { if(value == null) return false; - return value.getLanguage().equals(this.language) && value.getValue().matches(valuePattern); + return value.getLanguage().equals(this.language) && + (StringUtils.hasText(value.getValue()) && value.getValue().matches(valuePattern)); } }