Extract validation functions in the separate file
This commit is contained in:
@@ -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]}
|
||||
>
|
||||
<option value="" disabled={enabled}>
|
||||
{t('dhcp_interface_select')}
|
||||
@@ -125,7 +123,7 @@ let Form = (props) => {
|
||||
type="text"
|
||||
className="form-control"
|
||||
placeholder={t('dhcp_form_gateway_input')}
|
||||
validate={[ipv4, required]}
|
||||
validate={[validateIpv4, validateRequiredValue]}
|
||||
/>
|
||||
</div>
|
||||
<div className="form__group form__group--settings">
|
||||
@@ -137,7 +135,7 @@ let Form = (props) => {
|
||||
type="text"
|
||||
className="form-control"
|
||||
placeholder={t('dhcp_form_subnet_input')}
|
||||
validate={[ipv4, required]}
|
||||
validate={[validateIpv4, validateRequiredValue]}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
@@ -155,7 +153,7 @@ let Form = (props) => {
|
||||
type="text"
|
||||
className="form-control"
|
||||
placeholder={t('dhcp_form_range_start')}
|
||||
validate={[ipv4, required]}
|
||||
validate={[validateIpv4, validateRequiredValue]}
|
||||
/>
|
||||
</div>
|
||||
<div className="col">
|
||||
@@ -166,7 +164,7 @@ let Form = (props) => {
|
||||
type="text"
|
||||
className="form-control"
|
||||
placeholder={t('dhcp_form_range_end')}
|
||||
validate={[ipv4, required]}
|
||||
validate={[validateIpv4, validateRequiredValue]}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
@@ -179,7 +177,7 @@ let Form = (props) => {
|
||||
type="number"
|
||||
className="form-control"
|
||||
placeholder={t('dhcp_form_lease_input')}
|
||||
validate={[required, isPositive]}
|
||||
validate={[validateRequiredValue, validateIsPositiveValue]}
|
||||
normalize={toNumber}
|
||||
/>
|
||||
</div>
|
||||
|
||||
@@ -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, ipv4, mac, required,
|
||||
} from '../../../../helpers/form';
|
||||
import { renderInputField } from '../../../../helpers/form';
|
||||
import { validateIpv4, validateMac, validateRequiredValue } from '../../../../helpers/validators';
|
||||
import { FORM_NAME } from '../../../../helpers/constants';
|
||||
|
||||
const Form = (props) => {
|
||||
@@ -31,7 +29,7 @@ const Form = (props) => {
|
||||
type="text"
|
||||
className="form-control"
|
||||
placeholder={t('form_enter_mac')}
|
||||
validate={[required, mac]}
|
||||
validate={[validateRequiredValue, validateMac]}
|
||||
/>
|
||||
</div>
|
||||
<div className="form__group">
|
||||
@@ -42,7 +40,7 @@ const Form = (props) => {
|
||||
type="text"
|
||||
className="form-control"
|
||||
placeholder={t('form_enter_ip')}
|
||||
validate={[required, ipv4]}
|
||||
validate={[validateRequiredValue, validateIpv4]}
|
||||
/>
|
||||
</div>
|
||||
<div className="form__group">
|
||||
|
||||
Reference in New Issue
Block a user