Skip to content

Commit

Permalink
renames ViolationChild.path to fieldName
Browse files Browse the repository at this point in the history
  • Loading branch information
Peter Cornell committed Jan 25, 2019
1 parent cfc5511 commit 4d924ba
Show file tree
Hide file tree
Showing 9 changed files with 39 additions and 39 deletions.
16 changes: 8 additions & 8 deletions data/test/validation/constraints/content.isl
Original file line number Diff line number Diff line change
Expand Up @@ -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 },
],
},
],
Expand Down Expand Up @@ -53,7 +53,7 @@ test_validation::{
constraint: { content: closed },
code: unexpected_content,
children: [
{ path: "d", value: d },
{ fieldName: "d", value: d },
],
},
{
Expand All @@ -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 },
],
},
],
Expand Down
6 changes: 3 additions & 3 deletions data/test/validation/constraints/element.isl
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ test_validation::{
code: fields_mismatch,
children: [
{
path: "b",
fieldName: "b",
value: "hi",
violations: [
{
Expand All @@ -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: [
{
Expand Down
24 changes: 12 additions & 12 deletions data/test/validation/constraints/fields.isl
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ test_validation::{
code: fields_mismatch,
children: [
{
path: "one",
fieldName: "one",
value: 1.0,
violations: [ { constraint: { type: int }, code: type_mismatch } ],
},
Expand Down Expand Up @@ -55,15 +55,15 @@ test_validation::{
code: fields_mismatch,
children: [
{
path: "one",
fieldName: "one",
value: { two: 2.0 },
violations: [
{
constraint: { fields: { two: int } },
code: fields_mismatch,
children: [
{
path: "two",
fieldName: "two",
value: 2.0,
violations: [
{ constraint: { type: int }, code: type_mismatch },
Expand Down Expand Up @@ -102,29 +102,29 @@ 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 },
{ constraint: { codepoint_length: range::[4, 6] }, code: invalid_codepoint_length },
],
},
{
path: "four",
fieldName: "four",
violations: [
{ constraint: { occurs: required }, code: occurs_mismatch },
],
Expand Down Expand Up @@ -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",
Expand All @@ -200,7 +200,7 @@ test_validation::{
code: fields_mismatch,
children: [
{
path: "pretitle",
fieldName: "pretitle",
value: blah,
violations: [
{
Expand All @@ -210,7 +210,7 @@ test_validation::{
],
},
{
path: "title",
fieldName: "title",
value: "The Title of this Book is Too Long",
violations: [
{
Expand All @@ -226,7 +226,7 @@ test_validation::{
],
},
{
path: "subtitle",
fieldName: "subtitle",
value: "abc",
violations: [
{
Expand All @@ -236,7 +236,7 @@ test_validation::{
],
},
{
path: "subsubtitle",
fieldName: "subsubtitle",
value: "xyz",
violations: [
{
Expand Down
2 changes: 1 addition & 1 deletion data/test/validation/constraints/not.isl
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ test_validation::{
code: fields_mismatch,
children: [
{
path: "one",
fieldName: "one",
value: "hi",
violations: [
{
Expand Down
6 changes: 3 additions & 3 deletions data/test/validation/constraints/occurs.isl
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ test_validation::{
code: fields_mismatch,
children: [
{
path: "a",
fieldName: "a",
value: { a: 1, a: 2 },
violations: [
{
Expand All @@ -33,7 +33,7 @@ test_validation::{
],
},
{
path: "b",
fieldName: "b",
violations: [
{
constraint: { occurs: range::[1, 1] },
Expand All @@ -42,7 +42,7 @@ test_validation::{
],
},
{
path: "c",
fieldName: "c",
value: { c: 1, c: 2, c: 3, c: 4 },
violations: [
{
Expand Down
12 changes: 6 additions & 6 deletions data/test/validation/creature.isl
Original file line number Diff line number Diff line change
Expand Up @@ -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 } ],
},
Expand All @@ -118,7 +118,7 @@ test_validation::{
code: fields_mismatch,
children: [
{
path: "class",
fieldName: "class",
value: mammal,
violations: [ { constraint: { valid_values: [reptile] }, code: invalid_value } ],
},
Expand All @@ -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 } ],
},
],
Expand All @@ -167,7 +167,7 @@ test_validation::{
code: fields_mismatch,
children: [
{
path: "class",
fieldName: "class",
value: mammal,
violations: [ { constraint: { valid_values: [reptile] }, code: invalid_value } ],
},
Expand All @@ -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 },
Expand Down
6 changes: 3 additions & 3 deletions src/software/amazon/ionschema/Violations.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -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() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
4 changes: 2 additions & 2 deletions test/software/amazon/ionschema/IonSchemaTestSuite.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down

0 comments on commit 4d924ba

Please sign in to comment.