Skip to content

Commit 597d69a

Browse files
elanmartstainless-app[bot]
authored andcommitted
fix(api): add type guards to ConditionalValue deserializer
1 parent 3c948bc commit 597d69a

1 file changed

Lines changed: 18 additions & 6 deletions

File tree

lithic-java-core/src/main/kotlin/com/lithic/api/models/ConditionalValue.kt

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -195,14 +195,26 @@ private constructor(
195195

196196
val bestMatches =
197197
sequenceOf(
198-
tryDeserialize(node, jacksonTypeRef<String>())?.let {
199-
ConditionalValue(regex = it, _json = json)
198+
if (node.isTextual) {
199+
tryDeserialize(node, jacksonTypeRef<String>())?.let {
200+
ConditionalValue(regex = it, _json = json)
201+
}
202+
} else {
203+
null
200204
},
201-
tryDeserialize(node, jacksonTypeRef<Long>())?.let {
202-
ConditionalValue(number = it, _json = json)
205+
if (node.isNumber) {
206+
tryDeserialize(node, jacksonTypeRef<Long>())?.let {
207+
ConditionalValue(number = it, _json = json)
208+
}
209+
} else {
210+
null
203211
},
204-
tryDeserialize(node, jacksonTypeRef<List<String>>())?.let {
205-
ConditionalValue(listOfStrings = it, _json = json)
212+
if (node.isArray) {
213+
tryDeserialize(node, jacksonTypeRef<List<String>>())?.let {
214+
ConditionalValue(listOfStrings = it, _json = json)
215+
}
216+
} else {
217+
null
206218
},
207219
)
208220
.filterNotNull()

0 commit comments

Comments
 (0)