From 2fdf27cfc2c2a2111e84e7a7e29ac47f189df84f Mon Sep 17 00:00:00 2001 From: Claudia Malzer Date: Tue, 30 Jan 2024 13:54:49 +0100 Subject: [PATCH] ERM-2981 Standardise use of external url validator library across ERM apps * fix export error --- lib/utils/index.js | 3 +-- lib/utils/validators.js | 13 ++++++------- 2 files changed, 7 insertions(+), 9 deletions(-) diff --git a/lib/utils/index.js b/lib/utils/index.js index 11c2ab6b..b81f84db 100644 --- a/lib/utils/index.js +++ b/lib/utils/index.js @@ -13,8 +13,7 @@ export { required as requiredValidator, requiredObject as requiredObjectValidator, validateURL, - validateURLAndLength, - validateURLSize + validateURLAndLength } from './validators'; // Tag configuration for consistency across ERM apps diff --git a/lib/utils/validators.js b/lib/utils/validators.js index ad9e6802..88a0c520 100644 --- a/lib/utils/validators.js +++ b/lib/utils/validators.js @@ -12,7 +12,7 @@ import isURL from 'validator/lib/isURL'; const min = Number.MIN_SAFE_INTEGER; const max = Number.MAX_SAFE_INTEGER; -const validateProps = { allow_underscores: true }; +const isURLProps = { allow_underscores: true }; const invalidNumber = value => ( invalidNumberValidator(value, min, max, 'stripes-erm-components') @@ -27,12 +27,12 @@ const rangeUnderflow = value => ( ); const validateURL = (value) => { - const isURLProps = { - ...validateProps, + const validateProps = { + ...isURLProps, validate_length: false }; if (value) { - if (!isURL(value, isURLProps)) { + if (!isURL(value, validateProps)) { return ; } } @@ -42,7 +42,7 @@ const validateURL = (value) => { const validateURLAndLength = (value) => { if (value) { - if (!isURL(value, validateProps)) { + if (!isURL(value, isURLProps)) { return ; } } @@ -59,6 +59,5 @@ export { required, requiredObject, validateURL, - validateURLAndLength, - validateURLSize + validateURLAndLength };