diff --git a/client/src/components/Filters/Form.js b/client/src/components/Filters/Form.js index 46e0579d..0237a5d6 100644 --- a/client/src/components/Filters/Form.js +++ b/client/src/components/Filters/Form.js @@ -3,8 +3,8 @@ import PropTypes from 'prop-types'; import { Field, reduxForm } from 'redux-form'; import { Trans, withTranslation } from 'react-i18next'; import flow from 'lodash/flow'; - -import { renderInputField, required, isValidPath } from '../../helpers/form'; +import { renderInputField } from '../../helpers/form'; +import { validatePath, validateRequiredValue } from '../../helpers/validators'; import { FORM_NAME } from '../../helpers/constants'; const Form = (props) => { @@ -28,7 +28,7 @@ const Form = (props) => { component={renderInputField} className="form-control" placeholder={t('enter_name_hint')} - validate={[required]} + validate={[validateRequiredValue]} normalizeOnBlur={(data) => data.trim()} /> @@ -40,7 +40,7 @@ const Form = (props) => { component={renderInputField} className="form-control" placeholder={t('enter_url_or_path_hint')} - validate={[required, isValidPath]} + validate={[validateRequiredValue, validatePath]} normalizeOnBlur={(data) => data.trim()} /> diff --git a/client/src/components/Filters/Rewrites/Form.js b/client/src/components/Filters/Rewrites/Form.js index 5382ee32..2db7be35 100644 --- a/client/src/components/Filters/Rewrites/Form.js +++ b/client/src/components/Filters/Rewrites/Form.js @@ -3,10 +3,8 @@ import PropTypes from 'prop-types'; import { Field, reduxForm } from 'redux-form'; import { Trans, withTranslation } from 'react-i18next'; import flow from 'lodash/flow'; - -import { - renderInputField, required, domain, answer, -} from '../../../helpers/form'; +import { renderInputField } from '../../../helpers/form'; +import { validateAnswer, validateDomain, validateRequiredValue } from '../../../helpers/validators'; import { FORM_NAME } from '../../../helpers/constants'; const Form = (props) => { @@ -34,7 +32,7 @@ const Form = (props) => { type="text" className="form-control" placeholder={t('form_domain')} - validate={[required, domain]} + validate={[validateRequiredValue, validateDomain]} /> @@ -61,7 +59,7 @@ const Form = (props) => { type="text" className="form-control" placeholder={t('form_answer')} - validate={[required, answer]} + validate={[validateRequiredValue, validateAnswer]} /> diff --git a/client/src/components/Settings/Clients/Form.js b/client/src/components/Settings/Clients/Form.js index 65c16cb3..5c7bf471 100644 --- a/client/src/components/Settings/Clients/Form.js +++ b/client/src/components/Settings/Clients/Form.js @@ -13,13 +13,12 @@ import Tabs from '../../ui/Tabs'; import Examples from '../Dns/Upstream/Examples'; import { toggleAllServices } from '../../../helpers/helpers'; import { - required, - clientId, renderInputField, renderGroupField, renderSelectField, renderServiceField, } from '../../../helpers/form'; +import { validateClientId, validateRequiredValue } from '../../../helpers/validators'; import { FORM_NAME, SERVICES } from '../../../helpers/constants'; import './Service.css'; @@ -48,12 +47,12 @@ const settingsCheckboxes = [ const validate = (values) => { const errors = {}; const { name, ids } = values; - errors.name = required(name); + errors.name = validateRequiredValue(name); if (ids && ids.length) { const idArrayErrors = []; ids.forEach((id, idx) => { - idArrayErrors[idx] = required(id) || clientId(id); + idArrayErrors[idx] = validateRequiredValue(id) || validateClientId(id); }); if (idArrayErrors.length) { diff --git a/client/src/components/Settings/Dhcp/Form.js b/client/src/components/Settings/Dhcp/Form.js index 6e0a134f..6fd8c40e 100644 --- a/client/src/components/Settings/Dhcp/Form.js +++ b/client/src/components/Settings/Dhcp/Form.js @@ -4,11 +4,9 @@ import PropTypes from 'prop-types'; import { Field, reduxForm, formValueSelector } from 'redux-form'; import { Trans, withTranslation } from 'react-i18next'; import flow from 'lodash/flow'; - -import { - renderInputField, required, ipv4, isPositive, toNumber, -} from '../../../helpers/form'; +import { renderInputField, toNumber } from '../../../helpers/form'; import { FORM_NAME } from '../../../helpers/constants'; +import { validateIpv4, validateIsPositiveValue, validateRequiredValue } from '../../../helpers/validators'; const renderInterfaces = ((interfaces) => ( Object.keys(interfaces).map((item) => { @@ -96,7 +94,7 @@ let Form = (props) => { name="interface_name" component="select" className="form-control custom-select" - validate={[required]} + validate={[validateRequiredValue]} >