Skip to content

Commit

Permalink
ERM-2981 Standardise use of external url validator library across ERM…
Browse files Browse the repository at this point in the history
… apps

* fix export error
  • Loading branch information
CalamityC committed Jan 30, 2024
1 parent 4fa905b commit 2fdf27c
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 9 deletions.
3 changes: 1 addition & 2 deletions lib/utils/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,7 @@ export {
required as requiredValidator,
requiredObject as requiredObjectValidator,
validateURL,
validateURLAndLength,
validateURLSize
validateURLAndLength
} from './validators';

// Tag configuration for consistency across ERM apps
Expand Down
13 changes: 6 additions & 7 deletions lib/utils/validators.js
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand All @@ -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 <FormattedMessage id="stripes-erm-components.url.error.invalidURL" />;
}
}
Expand All @@ -42,7 +42,7 @@ const validateURL = (value) => {

const validateURLAndLength = (value) => {
if (value) {
if (!isURL(value, validateProps)) {
if (!isURL(value, isURLProps)) {
return <FormattedMessage id="stripes-erm-components.url.error.invalidURL" />;
}
}
Expand All @@ -59,6 +59,5 @@ export {
required,
requiredObject,
validateURL,
validateURLAndLength,
validateURLSize
validateURLAndLength
};

0 comments on commit 2fdf27c

Please sign in to comment.