fix(ui): Add additional URL & email input validation (#843)

This commit is contained in:
TheCatLady
2021-02-04 20:12:51 -05:00
committed by GitHub
parent b9d14a9fd0
commit 3f9bfeb01a
9 changed files with 92 additions and 25 deletions

View File

@@ -52,6 +52,8 @@ const messages = defineMessages({
preventSearch: 'Disable Auto-Search',
validationApplicationUrl: 'You must provide a valid URL',
validationApplicationUrlTrailingSlash: 'URL must not end in a trailing slash',
validationBaseUrlLeadingSlash: 'Base URL must have a leading slash',
validationBaseUrlTrailingSlash: 'Base URL must not end in a trailing slash',
});
interface TestResponse {
@@ -119,6 +121,27 @@ const RadarrModal: React.FC<RadarrModalProps> = ({
return true;
}
),
baseUrl: Yup.string()
.test(
'leading-slash',
intl.formatMessage(messages.validationBaseUrlLeadingSlash),
(value) => {
if (value && value?.substr(0, 1) !== '/') {
return false;
}
return true;
}
)
.test(
'no-trailing-slash',
intl.formatMessage(messages.validationBaseUrlTrailingSlash),
(value) => {
if (value?.substr(value.length - 1) === '/') {
return false;
}
return true;
}
),
});
const testConnection = useCallback(