Skip to content

Commit

Permalink
Throw on invalid custom fields
Browse files Browse the repository at this point in the history
  • Loading branch information
NSeydoux committed Dec 11, 2024
1 parent 1bcb3e2 commit a373ac8
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/type/CustomField.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,12 @@ export const toJson = (
`All custom fields keys must be URL objects, found ${field.key}`,
);
}
if (!["string", "number", "boolean"].includes(typeof field.value)) {
// FIXME use inrupt error library
throw new Error(
`All custom fields values must be literals, found ${field.value} (or type ${typeof field.value})`,
);
}
return { [`${field.key.toString()}`]: field.value };
})
// Collapse all the JSON object entries into a single object.
Expand Down

0 comments on commit a373ac8

Please sign in to comment.