final Type typeOfMap = new TypeToken<Map<String, Object>>() {}.getType();
this.fromApiJsonHelper.checkForUnsupportedParameters(typeOfMap, json, this.supportedParameters);
final List<ApiParameterError> dataValidationErrors = new ArrayList<>();
final DataValidatorBuilder baseDataValidator = new DataValidatorBuilder(dataValidationErrors).resource("staff");
final JsonElement element = this.fromApiJsonHelper.parse(json);
if (this.fromApiJsonHelper.parameterExists("officeId", element)) {
final Long officeId = this.fromApiJsonHelper.extractLongNamed("officeId", element);
baseDataValidator.reset().parameter("officeId").value(officeId).notNull().integerGreaterThanZero();
}
if (this.fromApiJsonHelper.parameterExists("firstname", element)) {
final String firstname = this.fromApiJsonHelper.extractStringNamed("firstname", element);
baseDataValidator.reset().parameter("firstname").value(firstname).notBlank().notExceedingLengthOf(50);
}
if (this.fromApiJsonHelper.parameterExists("lastname", element)) {
final String lastname = this.fromApiJsonHelper.extractStringNamed("lastname", element);
baseDataValidator.reset().parameter("lastname").value(lastname).notBlank().notExceedingLengthOf(50);
}
if (this.fromApiJsonHelper.parameterExists(ClientApiConstants.mobileNoParamName, element)) {
final String mobileNo = this.fromApiJsonHelper.extractStringNamed(ClientApiConstants.mobileNoParamName, element);
baseDataValidator.reset().parameter(ClientApiConstants.mobileNoParamName).value(mobileNo).notExceedingLengthOf(50);
}
if (this.fromApiJsonHelper.parameterExists("isLoanOfficer", element)) {
final Boolean loanOfficerFlag = this.fromApiJsonHelper.extractBooleanNamed("isLoanOfficer", element);
baseDataValidator.reset().parameter("isLoanOfficer").value(loanOfficerFlag).notNull();
}
if (this.fromApiJsonHelper.parameterExists("isActive", element)) {
final Boolean activeFlag = this.fromApiJsonHelper.extractBooleanNamed("isActive", element);
baseDataValidator.reset().parameter("isActive").value(activeFlag).notNull();
}
if (this.fromApiJsonHelper.parameterExists("joiningDate", element)) {
final LocalDate joiningDate = this.fromApiJsonHelper.extractLocalDateNamed("joiningDate", element);
baseDataValidator.reset().parameter("joiningDate").value(joiningDate).notNull();
}
if (this.fromApiJsonHelper.parameterExists("dateFormat", element)) {
final String dateFormat = this.fromApiJsonHelper.extractStringNamed("dateFormat", element);
baseDataValidator.reset().parameter("dateFormat").value(dateFormat).notBlank();
}
if (this.fromApiJsonHelper.parameterExists("locale", element)) {
final String locale = this.fromApiJsonHelper.extractStringNamed("locale", element);
baseDataValidator.reset().parameter("locale").value(locale).notBlank();
}
throwExceptionIfValidationWarningsExist(dataValidationErrors);
}