Skip to content

Commit

Permalink
fix validation exception for missing property nodes
Browse files Browse the repository at this point in the history
  • Loading branch information
s-tittel committed Aug 2, 2023
1 parent 252fb66 commit 907a90b
Showing 1 changed file with 13 additions and 10 deletions.
23 changes: 13 additions & 10 deletions src/form.ts
Original file line number Diff line number Diff line change
Expand Up @@ -119,18 +119,21 @@ export class ShaclForm extends HTMLElement {

if (showHints) {
for (const result of report.results) {
const invalidElement = this.querySelector(`:scope [data-node-id='${result.focusNode.id}'] [data-path='${result.path.id}']`)
if (invalidElement) {
const messageElement = document.createElement('pre')
messageElement.classList.add('validation')
if (result.message.length > 0) {
for (const message of result.message) {
messageElement.innerText += message + '\n'
// result.path can be null, e.g. if a focus node does not contain a required property node
if (result.path) {
const invalidElement = this.querySelector(`:scope [data-node-id='${result.focusNode.id}'] [data-path='${result.path.id}']`)
if (invalidElement) {
const messageElement = document.createElement('pre')
messageElement.classList.add('validation')
if (result.message.length > 0) {
for (const message of result.message) {
messageElement.innerText += message + '\n'
}
} else {
messageElement.innerText += result.sourceConstraintComponent.value
}
} else {
messageElement.innerText += result.sourceConstraintComponent.value
invalidElement.appendChild(messageElement)
}
invalidElement.appendChild(messageElement)
}
}
}
Expand Down

0 comments on commit 907a90b

Please sign in to comment.