Skip to content

Commit

Permalink
Merge pull request #3347 from LD4P/t3259-validation
Browse files Browse the repository at this point in the history
Validate literals as literals, not URIs.
  • Loading branch information
justinlittman authored Nov 17, 2021
2 parents 0247630 + f8392fc commit adecce1
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 4 deletions.
8 changes: 8 additions & 0 deletions __tests__/reducers/resourceValidationHelpers.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ describe("new literal value with validationDataType of integer", () => {
uri: null,
label: null,
valueSubjectKey: null,
component: "InputLiteralValue",
},
},
}
Expand Down Expand Up @@ -60,6 +61,7 @@ describe("new literal value with validationDataType of integer", () => {
uri: null,
label: null,
valueSubjectKey: null,
component: "InputLiteralValue",
},
},
}
Expand Down Expand Up @@ -161,6 +163,7 @@ describe("new literal value with validationDataType of dateTime", () => {
uri: null,
label: null,
valueSubjectKey: null,
component: "InputLiteralValue",
},
},
}
Expand Down Expand Up @@ -189,6 +192,7 @@ describe("new literal value with validationDataType of dateTime", () => {
uri: null,
label: null,
valueSubjectKey: null,
component: "InputLiteralValue",
},
},
}
Expand Down Expand Up @@ -217,6 +221,7 @@ describe("new literal value with validationDataType of dateTime", () => {
uri: null,
label: null,
valueSubjectKey: null,
component: "InputLiteralValue",
},
},
}
Expand Down Expand Up @@ -249,6 +254,7 @@ describe("new literal value with validationDataType of dateTimeStamp", () => {
uri: null,
label: null,
valueSubjectKey: null,
component: "InputLiteralValue",
},
},
}
Expand Down Expand Up @@ -277,6 +283,7 @@ describe("new literal value with validationDataType of dateTimeStamp", () => {
uri: null,
label: null,
valueSubjectKey: null,
component: "InputLiteralValue",
},
},
}
Expand Down Expand Up @@ -305,6 +312,7 @@ describe("new literal value with validationDataType of dateTimeStamp", () => {
uri: null,
label: null,
valueSubjectKey: null,
component: "InputLiteralValue",
},
},
}
Expand Down
2 changes: 2 additions & 0 deletions __tests__/reducers/resources.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -532,6 +532,7 @@ describe("addValue()", () => {
uri: null,
label: null,
valueSubjectKey: null,
component: "InputLiteralValue",
},
},
}
Expand All @@ -549,6 +550,7 @@ describe("addValue()", () => {
label: null,
valueSubjectKey: null,
errors: ["Literal required"],
component: "InputLiteralValue",
})
expect(newState.properties["JQEtq-vmq8"].valueKeys).toContain("DxGx7WMh3")
expect(newState.properties["JQEtq-vmq8"].show).toBe(true)
Expand Down
6 changes: 2 additions & 4 deletions src/reducers/resourceHelpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -188,17 +188,15 @@ export const updateValueErrors = (state, valueKey) => {
const propertyTemplate = state.propertyTemplates[property.propertyTemplateKey]
// If this is first value, then must have a value.
const errors = []
if (propertyTemplate.type === "literal") {
if (value.component === "InputLiteralValue") {
errors.push(literalRequiredError(value, property, propertyTemplate))
if (value.literal !== null && value.literal !== "") {
errors.push(literalRegexValidationError(value, propertyTemplate))
errors.push(literalIntegerValidationError(value, propertyTemplate))
errors.push(literalDateTimeValidationError(value, propertyTemplate))
errors.push(literalDateTimeStampValidationError(value, propertyTemplate))
}
}

if (propertyTemplate.type === "uri") {
} else if (propertyTemplate.type === "uri") {
errors.push(uriPropertiesAndValueErrors(value, property, propertyTemplate))
}

Expand Down

0 comments on commit adecce1

Please sign in to comment.