diff --git a/data/test/validation/constraints/content.isl b/data/test/validation/constraints/content.isl index f5668b8e..f81fb44f 100644 --- a/data/test/validation/constraints/content.isl +++ b/data/test/validation/constraints/content.isl @@ -15,11 +15,11 @@ test_validation::{ constraint: { content: closed }, code: unexpected_content, children: [ - { path: "w", value: 0 }, - { path: "x", value: 1 }, - { path: "y", value: 2 }, - { path: "z", value: 3 }, - { path: "z", value: 4 }, + { fieldName: "w", value: 0 }, + { fieldName: "x", value: 1 }, + { fieldName: "y", value: 2 }, + { fieldName: "z", value: 3 }, + { fieldName: "z", value: 4 }, ], }, ], @@ -53,7 +53,7 @@ test_validation::{ constraint: { content: closed }, code: unexpected_content, children: [ - { path: "d", value: d }, + { fieldName: "d", value: d }, ], }, { @@ -78,14 +78,14 @@ test_validation::{ code: fields_mismatch, children: [ { - path: "c", + fieldName: "c", value: { z: z }, violations: [ { constraint: { content: closed }, code: unexpected_content, children: [ - { path: "z", value: z }, + { fieldName: "z", value: z }, ], }, ], diff --git a/data/test/validation/constraints/element.isl b/data/test/validation/constraints/element.isl index eacf0d6a..bbf032b6 100644 --- a/data/test/validation/constraints/element.isl +++ b/data/test/validation/constraints/element.isl @@ -142,7 +142,7 @@ test_validation::{ code: fields_mismatch, children: [ { - path: "b", + fieldName: "b", value: "hi", violations: [ { @@ -167,14 +167,14 @@ test_validation::{ code: fields_mismatch, children: [ { - path: "a", + fieldName: "a", value: true, violations: [ { constraint: { type: int }, code: type_mismatch }, ], }, { - path: "b", + fieldName: "b", value: hi, violations: [ { diff --git a/data/test/validation/constraints/fields.isl b/data/test/validation/constraints/fields.isl index 1b2cdd01..5168689c 100644 --- a/data/test/validation/constraints/fields.isl +++ b/data/test/validation/constraints/fields.isl @@ -27,7 +27,7 @@ test_validation::{ code: fields_mismatch, children: [ { - path: "one", + fieldName: "one", value: 1.0, violations: [ { constraint: { type: int }, code: type_mismatch } ], }, @@ -55,7 +55,7 @@ test_validation::{ code: fields_mismatch, children: [ { - path: "one", + fieldName: "one", value: { two: 2.0 }, violations: [ { @@ -63,7 +63,7 @@ test_validation::{ code: fields_mismatch, children: [ { - path: "two", + fieldName: "two", value: 2.0, violations: [ { constraint: { type: int }, code: type_mismatch }, @@ -102,21 +102,21 @@ test_validation::{ code: fields_mismatch, children: [ { - path: "one", + fieldName: "one", value: 1.0, violations: [ { constraint: { type: int }, code: type_mismatch }, ], }, { - path: "two", + fieldName: "two", value: "hi", violations: [ { constraint: { type: symbol }, code: type_mismatch }, ], }, { - path: "three", + fieldName: "three", value: "hello world", violations: [ { constraint: { type: symbol }, code: type_mismatch }, @@ -124,7 +124,7 @@ test_validation::{ ], }, { - path: "four", + fieldName: "four", violations: [ { constraint: { occurs: required }, code: occurs_mismatch }, ], @@ -176,7 +176,7 @@ test_validation::{ code: fields_mismatch, children: [ { - path: "favoriteBook", + fieldName: "favoriteBook", value: { pretitle: blah, title: "The Title of this Book is Too Long", @@ -200,7 +200,7 @@ test_validation::{ code: fields_mismatch, children: [ { - path: "pretitle", + fieldName: "pretitle", value: blah, violations: [ { @@ -210,7 +210,7 @@ test_validation::{ ], }, { - path: "title", + fieldName: "title", value: "The Title of this Book is Too Long", violations: [ { @@ -226,7 +226,7 @@ test_validation::{ ], }, { - path: "subtitle", + fieldName: "subtitle", value: "abc", violations: [ { @@ -236,7 +236,7 @@ test_validation::{ ], }, { - path: "subsubtitle", + fieldName: "subsubtitle", value: "xyz", violations: [ { diff --git a/data/test/validation/constraints/not.isl b/data/test/validation/constraints/not.isl index d5ff2b38..e79dc45e 100644 --- a/data/test/validation/constraints/not.isl +++ b/data/test/validation/constraints/not.isl @@ -12,7 +12,7 @@ test_validation::{ code: fields_mismatch, children: [ { - path: "one", + fieldName: "one", value: "hi", violations: [ { diff --git a/data/test/validation/constraints/occurs.isl b/data/test/validation/constraints/occurs.isl index baa39d22..dc561908 100644 --- a/data/test/validation/constraints/occurs.isl +++ b/data/test/validation/constraints/occurs.isl @@ -23,7 +23,7 @@ test_validation::{ code: fields_mismatch, children: [ { - path: "a", + fieldName: "a", value: { a: 1, a: 2 }, violations: [ { @@ -33,7 +33,7 @@ test_validation::{ ], }, { - path: "b", + fieldName: "b", violations: [ { constraint: { occurs: range::[1, 1] }, @@ -42,7 +42,7 @@ test_validation::{ ], }, { - path: "c", + fieldName: "c", value: { c: 1, c: 2, c: 3, c: 4 }, violations: [ { diff --git a/data/test/validation/creature.isl b/data/test/validation/creature.isl index 2daf2040..b791bef6 100644 --- a/data/test/validation/creature.isl +++ b/data/test/validation/creature.isl @@ -95,7 +95,7 @@ test_validation::{ code: fields_mismatch, children: [ { - path: "appendage_count", + fieldName: "appendage_count", value: 4, violations: [ { constraint: { valid_values: [2] }, code: invalid_value } ], }, @@ -118,7 +118,7 @@ test_validation::{ code: fields_mismatch, children: [ { - path: "class", + fieldName: "class", value: mammal, violations: [ { constraint: { valid_values: [reptile] }, code: invalid_value } ], }, @@ -141,12 +141,12 @@ test_validation::{ code: fields_mismatch, children: [ { - path: "class", + fieldName: "class", value: mammal, violations: [ { constraint: { valid_values: [cephalopod] }, code: invalid_value } ], }, { - path: "tentacle_count", + fieldName: "tentacle_count", violations: [ { constraint: { occurs: required }, code: occurs_mismatch } ], }, ], @@ -167,7 +167,7 @@ test_validation::{ code: fields_mismatch, children: [ { - path: "class", + fieldName: "class", value: mammal, violations: [ { constraint: { valid_values: [reptile] }, code: invalid_value } ], }, @@ -184,7 +184,7 @@ test_validation::{ code: fields_mismatch, children: [ { - path: "appendage_count", + fieldName: "appendage_count", value: 4, violations: [ { constraint: { valid_values: [5] }, code: invalid_value }, diff --git a/src/software/amazon/ionschema/Violations.kt b/src/software/amazon/ionschema/Violations.kt index 52d239b2..e0b84af7 100644 --- a/src/software/amazon/ionschema/Violations.kt +++ b/src/software/amazon/ionschema/Violations.kt @@ -92,7 +92,7 @@ open class Violations internal constructor ( children.forEach { sb.append(" ".repeat(2 * depth)) sb.append("- ") - it.path?.let { sb.append(it) } + it.fieldName?.let { sb.append(it) } it.index?.let { sb.append("[").append(it).append("]") } it.value?.let { sb.append(": ").append(it.toString().truncate(20)) } sb.appendln() @@ -111,11 +111,11 @@ class Violation( ) : Violations() /** - * References a specific path (struct field) or index of a list/sexp/document + * References a specific struct fieldName or index into a list/sexp/document * within a hierarchical Violations object. */ class ViolationChild internal constructor ( - val path: String? = null, + val fieldName: String? = null, val index: Int? = null, var value: IonValue? = null ) : Violations() { diff --git a/src/software/amazon/ionschema/internal/constraint/Fields.kt b/src/software/amazon/ionschema/internal/constraint/Fields.kt index 3ee50f68..61801ea3 100644 --- a/src/software/amazon/ionschema/internal/constraint/Fields.kt +++ b/src/software/amazon/ionschema/internal/constraint/Fields.kt @@ -45,7 +45,7 @@ internal class Fields( val fieldConstraints = ionStruct.associateBy( { it.fieldName }, { Pair(Occurs(it, schema, OPTIONAL, isField = true), - ViolationChild(path = it.fieldName)) + ViolationChild(fieldName = it.fieldName)) }) var closedContentIssues: Violation? = null diff --git a/test/software/amazon/ionschema/IonSchemaTestSuite.kt b/test/software/amazon/ionschema/IonSchemaTestSuite.kt index 8d590478..c05d9549 100644 --- a/test/software/amazon/ionschema/IonSchemaTestSuite.kt +++ b/test/software/amazon/ionschema/IonSchemaTestSuite.kt @@ -216,8 +216,8 @@ class IonSchemaTestSuite( private fun ViolationChild.toIon(): IonStruct { val struct = ION.newEmptyStruct() - if (path != null && !path.equals("")) { - struct.put("path", ION.newString(path)) + if (fieldName != null && !fieldName.equals("")) { + struct.put("fieldName", ION.newString(fieldName)) } if (index != null) { struct.put("index", ION.newInt(index as Int))