fix(ui): add validation to hostname/IP fields (#1206)

pull/1208/head^2
TheCatLady 4 years ago committed by GitHub
parent eb6807b9e2
commit f49a02449c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -73,9 +73,13 @@ const NotificationsEmail: React.FC = () => {
emailFrom: Yup.string() emailFrom: Yup.string()
.required(intl.formatMessage(messages.validationEmail)) .required(intl.formatMessage(messages.validationEmail))
.email(intl.formatMessage(messages.validationEmail)), .email(intl.formatMessage(messages.validationEmail)),
smtpHost: Yup.string().required( smtpHost: Yup.string()
intl.formatMessage(messages.validationSmtpHostRequired) .required(intl.formatMessage(messages.validationSmtpHostRequired))
), .matches(
// eslint-disable-next-line
/^(([a-z]|\d|_|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*)?([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])$/i,
intl.formatMessage(messages.validationSmtpHostRequired)
),
smtpPort: Yup.number().required( smtpPort: Yup.number().required(
intl.formatMessage(messages.validationSmtpPortRequired) intl.formatMessage(messages.validationSmtpPortRequired)
), ),

@ -91,9 +91,13 @@ const RadarrModal: React.FC<RadarrModalProps> = ({
name: Yup.string().required( name: Yup.string().required(
intl.formatMessage(messages.validationNameRequired) intl.formatMessage(messages.validationNameRequired)
), ),
hostname: Yup.string().required( hostname: Yup.string()
intl.formatMessage(messages.validationHostnameRequired) .required(intl.formatMessage(messages.validationHostnameRequired))
), .matches(
// eslint-disable-next-line
/^(([a-z]|\d|_|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*)?([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])$/i,
intl.formatMessage(messages.validationHostnameRequired)
),
port: Yup.number().required( port: Yup.number().required(
intl.formatMessage(messages.validationPortRequired) intl.formatMessage(messages.validationPortRequired)
), ),
@ -312,7 +316,12 @@ const RadarrModal: React.FC<RadarrModalProps> = ({
} }
}} }}
secondaryDisabled={ secondaryDisabled={
!values.apiKey || !values.hostname || !values.port || isTesting !values.apiKey ||
!values.hostname ||
!values.port ||
isTesting ||
isSubmitting ||
!isValid
} }
okDisabled={!isValidated || isSubmitting || isTesting || !isValid} okDisabled={!isValidated || isSubmitting || isTesting || !isValid}
onOk={() => handleSubmit()} onOk={() => handleSubmit()}

@ -113,9 +113,13 @@ const SettingsPlex: React.FC<SettingsPlexProps> = ({ onComplete }) => {
const intl = useIntl(); const intl = useIntl();
const { addToast, removeToast } = useToasts(); const { addToast, removeToast } = useToasts();
const PlexSettingsSchema = Yup.object().shape({ const PlexSettingsSchema = Yup.object().shape({
hostname: Yup.string().required( hostname: Yup.string()
intl.formatMessage(messages.validationHostnameRequired) .required(intl.formatMessage(messages.validationHostnameRequired))
), .matches(
// eslint-disable-next-line
/^(([a-z]|\d|_|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*)?([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])$/i,
intl.formatMessage(messages.validationHostnameRequired)
),
port: Yup.number().required( port: Yup.number().required(
intl.formatMessage(messages.validationPortRequired) intl.formatMessage(messages.validationPortRequired)
), ),

@ -102,9 +102,13 @@ const SonarrModal: React.FC<SonarrModalProps> = ({
name: Yup.string().required( name: Yup.string().required(
intl.formatMessage(messages.validationNameRequired) intl.formatMessage(messages.validationNameRequired)
), ),
hostname: Yup.string().required( hostname: Yup.string()
intl.formatMessage(messages.validationHostnameRequired) .required(intl.formatMessage(messages.validationHostnameRequired))
), .matches(
// eslint-disable-next-line
/^(([a-z]|\d|_|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*)?([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])$/i,
intl.formatMessage(messages.validationHostnameRequired)
),
port: Yup.number().required( port: Yup.number().required(
intl.formatMessage(messages.validationPortRequired) intl.formatMessage(messages.validationPortRequired)
), ),
@ -341,7 +345,12 @@ const SonarrModal: React.FC<SonarrModalProps> = ({
} }
}} }}
secondaryDisabled={ secondaryDisabled={
!values.apiKey || !values.hostname || !values.port || isTesting !values.apiKey ||
!values.hostname ||
!values.port ||
isTesting ||
isSubmitting ||
!isValid
} }
okDisabled={!isValidated || isSubmitting || isTesting || !isValid} okDisabled={!isValidated || isSubmitting || isTesting || !isValid}
onOk={() => handleSubmit()} onOk={() => handleSubmit()}

Loading…
Cancel
Save