Skip to content

Commit

Permalink
[model] tolerate to have null type before an actual type in model han…
Browse files Browse the repository at this point in the history
…dler
  • Loading branch information
rmannibucau committed Mar 19, 2024
1 parent bc0c326 commit c413b2d
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/main/java/io/yupiik/hcms/service/model/ModelHandler.java
Original file line number Diff line number Diff line change
Expand Up @@ -1143,6 +1143,7 @@ private SQLConsumer<PreparedStatement> findPropertyNullBinder(

return switch (model.type().stream()
.filter(Objects::nonNull)
.filter(i -> i != nullValue)
.findFirst()
.orElse(string)) {
case string -> model.format() == null
Expand Down Expand Up @@ -1383,7 +1384,11 @@ private String selectColumn(final String dbRevisionColumn, final Map.Entry<Strin
private Stream<String> validateEntityProperty(final Model.JsonSchema prop) {
return switch (prop.type() == null
? nullValue
: prop.type().stream().filter(Objects::nonNull).findFirst().orElse(nullValue)) {
: prop.type().stream()
.filter(Objects::nonNull)
.filter(i -> i != nullValue)
.findFirst()
.orElse(nullValue)) {
case nullValue, object, array -> Stream.of("Invalid property type, can't be '" + prop.type() + "'");
default -> Stream.empty();
};
Expand Down

0 comments on commit c413b2d

Please sign in to comment.