Done ticket GEPAFINBE-169

This commit is contained in:
nisha
2025-02-24 18:04:34 +05:30
parent 32617b0291
commit c2e8fa321c
8 changed files with 271 additions and 31 deletions

View File

@@ -415,8 +415,8 @@ public class FormDao {
}
FieldValidatorBean fieldValidatorBean = Utils.convertSourceObjectToDestinationObject(contentResponseBean.getValidators(), FieldValidatorBean.class);
validator
.minLength(value, fieldValidatorBean.getMinLength(), fieldLabel) // Only applies if minLength is not null
.maxLength(value, fieldValidatorBean.getMaxLength(), fieldLabel) // Only applies if maxLength is not null
.minLength(value, fieldValidatorBean.getMinLength(), fieldLabel,fieldValidatorBean.getMin(),contentResponseBean) // Only applies if minLength is not null
.maxLength(value, fieldValidatorBean.getMaxLength(), fieldLabel,fieldValidatorBean.getMax(),contentResponseBean) // Only applies if maxLength is not null
.matchesPattern(value, fieldValidatorBean.getPattern(), fieldLabel) // Only applies if pattern is present
.validateCustom(value, fieldValidatorBean.getCustom(), fieldLabel,contentResponseBean); // Add the custom validation here
if (fieldValidatorBean.getCustom() != null && fieldValidatorBean.getCustom().equals(GepafinConstant.IS_PIVA)) {
@@ -429,28 +429,34 @@ public class FormDao {
validator.validate();
}
private void checkObjectData(String fieldId, Object fieldValue, Map<String, Object> formFieldMap) {
if (fieldValue instanceof List<?>) {
public void checkObjectData(String fieldId, Object fieldValue, Map<String, Object> formFieldMap) {
if (fieldValue instanceof List<?>) {
List<?> list = (List<?>) fieldValue;
// Only map if the list is not empty and contains Strings
if (!list.isEmpty() && list.get(0) instanceof String) {
if (list.stream().allMatch(item -> item instanceof String)) {
formFieldMap.put(fieldId, list);
}
else if (!list.isEmpty() && list.get(0) instanceof String) {
for (Object value : list) {
setFormFieldMap(fieldId, formFieldMap, value);
}
}else if (list.stream().allMatch(item -> item instanceof Map<?, ?> map &&
}
else if (list.stream().allMatch(item -> item instanceof Map<?, ?> map &&
map.keySet().stream().allMatch(String.class::isInstance))) {
if (fieldValue != null) {
formFieldMap.put(fieldId, fieldValue);
}
} else setFormFieldMap(fieldId, formFieldMap, fieldValue);
}
else setFormFieldMap(fieldId, formFieldMap, fieldValue);
}
private void setFormFieldMap(String fieldId, Map<String, Object> formFieldMap, Object value) {
if (value instanceof String) {
if(value !=null && Boolean.FALSE.equals(StringUtils.isEmpty((String)value))) {
public void setFormFieldMap(String fieldId, Map<String, Object> formFieldMap, Object value) {
if(value !=null){
String fieldValue= String.valueOf(value);
if(Boolean.FALSE.equals(StringUtils.isEmpty(fieldValue))) {
formFieldMap.put(fieldId, value);
}
}
}
}