diff options
author | (quasar) nebula <qznebula@protonmail.com> | 2023-11-20 19:28:06 -0400 |
---|---|---|
committer | (quasar) nebula <qznebula@protonmail.com> | 2023-11-21 07:50:14 -0400 |
commit | 453b0e9845d41c7a1049d4f0982b66121626766a (patch) | |
tree | ec07b0a2e8567d06865c92ad336dc1001430ab79 | |
parent | 7f56163ad123b3ba8da431630d3da67f5444adb6 (diff) |
data: use optional in definitions for more utility validators
-rw-r--r-- | src/data/things/validators.js | 15 |
1 files changed, 6 insertions, 9 deletions
diff --git a/src/data/things/validators.js b/src/data/things/validators.js index f60c363c..19ad1c0a 100644 --- a/src/data/things/validators.js +++ b/src/data/things/validators.js @@ -96,7 +96,10 @@ export function isStringNonEmpty(value) { } export function optional(validator) { - return value => value === null || value === undefined || validator(value); + return value => + value === null || + value === undefined || + validator(value); } // Complex types (non-primitives) @@ -285,20 +288,14 @@ export function validateProperties(spec) { export const isContribution = validateProperties({ who: isArtistRef, - what: (value) => - value === undefined || - value === null || - isStringNonEmpty(value), + what: optional(isStringNonEmpty), }); export const isContributionList = validateArrayItems(isContribution); export const isAdditionalFile = validateProperties({ title: isString, - description: (value) => - value === undefined || - value === null || - isString(value), + description: optional(isStringNonEmpty), files: validateArrayItems(isString), }); |