in service/src/main/java/org/apache/fineract/cn/customer/catalog/internal/service/FieldValueValidator.java [57:89]
public void validateValues(final List<Value> values) {
values.forEach(value -> {
final CatalogEntity catalogEntity =
this.catalogRepository.findByIdentifier(value.getCatalogIdentifier())
.orElseThrow(() -> ServiceException.notFound("Catalog {0} not found.", value.getCatalogIdentifier()));
final FieldEntity fieldEntity =
this.fieldRepository.findByCatalogAndIdentifier(catalogEntity, value.getFieldIdentifier())
.orElseThrow(() -> ServiceException.notFound("Field {0} not found.", value.getFieldIdentifier()));
final Field.DataType dataType = Field.DataType.valueOf(fieldEntity.getDataType());
switch (dataType) {
case TEXT:
this.checkLength(value, fieldEntity);
break;
case NUMBER:
this.checkNumber(value, fieldEntity);
break;
case DATE:
this.checkDate(value, fieldEntity);
break;
case SINGLE_SELECTION:
this.checkOptions(value, fieldEntity, fieldEntity.getOptions(), true);
break;
case MULTI_SELECTION:
this.checkOptions(value, fieldEntity, fieldEntity.getOptions(), false);
break;
default:
throw ServiceException.badRequest("Unsupported data type {0} of field {1}.", dataType.name(), fieldEntity.getLabel());
}
});
}