From cc1a01870e287a756633e43b6f6d437434c4af32 Mon Sep 17 00:00:00 2001 From: "(quasar) nebula" Date: Thu, 11 Jun 2026 16:35:30 -0300 Subject: validators, yaml: URL OK!! --- src/validators.js | 33 +++++++++++++++++++++++++++++++-- 1 file changed, 31 insertions(+), 2 deletions(-) (limited to 'src/validators.js') diff --git a/src/validators.js b/src/validators.js index 28f3cef7..8f32e669 100644 --- a/src/validators.js +++ b/src/validators.js @@ -839,10 +839,39 @@ export const validateURLEntry = (isURL) => }); export const isURLEntry = - validateURLEntry(isURL); + validateProperties({ + url: isURL, + annotation: optional(isStringNonEmpty), + }); export const isCuratedURLEntry = - validateURLEntry(isCuratedURL); + (() => { + const commonProperties = { + annotation: optional(isStringNonEmpty), + }; + + const pickyValidator = + validateProperties({ + url: isCuratedURL, + ...commonProperties, + bypassValidation: optional(is(false)), + }); + + const niceysValidator = + validateProperties({ + url: isURL, + ...commonProperties, + bypassValidation: is(true), + }); + + return value => { + if (typeof value === 'object' && value.bypassValidation) { + return niceysValidator(value); + } else { + return pickyValidator(value); + } + }; + })(); export const isURLList = validateArrayItems(isURLEntry); -- cgit 1.3.0-6-gf8a5