Skip to content

Commit

Permalink
ES-391 fixed validation issue (#84)
Browse files Browse the repository at this point in the history
Signed-off-by: ase-101 <[email protected]>
Signed-off-by: Sreang Rathanak <[email protected]>
  • Loading branch information
ase-101 authored and Sreang Rathanak committed Jan 15, 2024
1 parent d2d896c commit a555381
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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));
}
}

0 comments on commit a555381

Please sign in to comment.