Skip to content

Commit 37f84a3

Browse files
committed
Add getValue internal function for ObjectElement
1 parent f3339d8 commit 37f84a3

File tree

2 files changed

+4
-1
lines changed

2 files changed

+4
-1
lines changed

json-schema-validator/src/commonMain/kotlin/io/github/optimumcode/json/schema/internal/util/ElementEqualityUtil.kt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import io.github.optimumcode.json.schema.model.AbstractElement
44
import io.github.optimumcode.json.schema.model.ArrayElement
55
import io.github.optimumcode.json.schema.model.ObjectElement
66
import io.github.optimumcode.json.schema.model.PrimitiveElement
7+
import io.github.optimumcode.json.schema.model.getValue
78

89
internal fun areEqual(
910
first: AbstractElement,
@@ -82,7 +83,7 @@ internal fun areEqualObjects(
8283
return false
8384
}
8485
for (key in first.keys) {
85-
if (!areEqual(first.get(key)!!, second.get(key)!!)) {
86+
if (!areEqual(first.getValue(key), second.getValue(key))) {
8687
return false
8788
}
8889
}

json-schema-validator/src/commonMain/kotlin/io/github/optimumcode/json/schema/model/Model.kt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,8 @@ public interface ObjectElement : AbstractElement, Sequence<Pair<String, Abstract
8585

8686
internal fun ObjectElement.isEmpty(): Boolean = size == 0
8787

88+
internal fun ObjectElement.getValue(key: String): AbstractElement = get(key) ?: error("property '$key' not found")
89+
8890
@ExperimentalApi
8991
public interface ArrayElement : AbstractElement, Sequence<AbstractElement> {
9092
/**

0 commit comments

Comments
 (0)