Replaced field value from fields name to its actual labled value.
This commit is contained in:
@@ -465,17 +465,27 @@ public class FormDao {
|
||||
String value = (String) formFieldMap.get(fieldId);
|
||||
|
||||
FieldValidatorBean fieldValidatorBean = Utils.convertSourceObjectToDestinationObject(contentResponseBean.getValidators(), FieldValidatorBean.class);
|
||||
validator
|
||||
.isRequired(value,fieldValidatorBean.getIsRequired(),contentResponseBean.getLabel());
|
||||
String fieldValue = getFieldValue(contentResponseBean);
|
||||
validator.isRequired(value, fieldValidatorBean.getIsRequired(), fieldValue);
|
||||
});
|
||||
if (Boolean.TRUE.equals(isSendValidationError)) {
|
||||
validator.validate();
|
||||
}
|
||||
if (validator.hasErrors()) {
|
||||
return false;
|
||||
return !validator.hasErrors();
|
||||
}
|
||||
return true;
|
||||
|
||||
private String getFieldValue(ContentResponseBean contentResponseBean) {
|
||||
// Use Optional with pattern matching for type checks
|
||||
return contentResponseBean.getSettings().stream().filter(setting -> "label".equals(setting.getName()) && setting.getValue() != null)
|
||||
.map(setting -> {
|
||||
if (setting.getValue() instanceof String value) {
|
||||
return value.trim();
|
||||
} else {
|
||||
return String.valueOf(setting.getValue()).trim();
|
||||
}
|
||||
}).filter(value -> !value.isEmpty()).findFirst().orElse(contentResponseBean.getId());
|
||||
}
|
||||
|
||||
public String validateVatNumber(String value,String customRule,String fieldId){
|
||||
String error=null;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user