Skip to content

Commit

Permalink
Support undefined values for overriding
Browse files Browse the repository at this point in the history
  • Loading branch information
NSeydoux committed Dec 12, 2024
1 parent c984735 commit 17f59f8
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/type/CustomField.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ export type CustomField = {
/* The custom field name (this must be a URL). */
key: URL;
/* The custom field value (this must be a literal). */
value: string | number | boolean;
value: string | number | boolean | undefined;
};

const WELL_KNOWN_FIELDS = [
Expand Down Expand Up @@ -68,7 +68,11 @@ export const toJson = (
`All custom fields keys must be URL objects, found ${field.key}`,
);
}
if (!["string", "number", "boolean"].includes(typeof field.value)) {
if (
!["string", "number", "boolean", "undefined"].includes(
typeof field.value,
)
) {
// FIXME use inrupt error library
throw new Error(
`All custom fields values must be literals, found ${JSON.stringify(field.value)} (of type ${typeof field.value})`,
Expand Down

0 comments on commit 17f59f8

Please sign in to comment.