Skip to content

Commit 473bf78

Browse files
[MOSIP-41856] added validation for zero or negative number for age value. (mosip#1550) (mosip#1552)
* [MOSIP-41856] added validation for zero or negative number for age value. * [MOSIP-41856] corrected error message. --------- Signed-off-by: Mahammed Taheer <mohd.taheer@gmail.com>
1 parent ffb854e commit 473bf78

1 file changed

Lines changed: 10 additions & 2 deletions

File tree

authentication/authentication-common/src/main/java/io/mosip/authentication/common/service/validator/BaseAuthRequestValidator.java

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -949,10 +949,18 @@ private void checkAge(AuthRequestDTO authRequest, Errors errors) {
949949
if (ageList != null) {
950950
for (IdentityInfoDTO identityInfoDTO : ageList) {
951951
try {
952-
Integer.parseInt(identityInfoDTO.getValue());
952+
int age = Integer.parseInt(identityInfoDTO.getValue());
953+
if (age <= 0) {
954+
mosipLogger.error(IdAuthCommonConstants.SESSION_ID, this.getClass().getSimpleName(),
955+
IdAuthCommonConstants.VALIDATE, "Demographic data – Age is not valid");
956+
errors.rejectValue(IdAuthCommonConstants.REQUEST,
957+
IdAuthenticationErrorConstants.INVALID_INPUT_PARAMETER.getErrorCode(),
958+
new Object[] { "age" },
959+
IdAuthenticationErrorConstants.INVALID_INPUT_PARAMETER.getErrorMessage());
960+
}
953961
} catch (NumberFormatException e) {
954962
mosipLogger.error(IdAuthCommonConstants.SESSION_ID, this.getClass().getSimpleName(),
955-
IdAuthCommonConstants.VALIDATE, "Demographic data – Age(pi) did not match");
963+
IdAuthCommonConstants.VALIDATE, "Demographic data – Age is not valid");
956964
errors.rejectValue(IdAuthCommonConstants.REQUEST,
957965
IdAuthenticationErrorConstants.INVALID_INPUT_PARAMETER.getErrorCode(),
958966
new Object[] { "age" },

0 commit comments

Comments
 (0)