Check is safe port

This commit is contained in:
Ildar Kamalov
2019-02-19 18:56:13 +03:00
parent 24154f0033
commit 77793e5f21
4 changed files with 78 additions and 3 deletions

View File

@@ -1,7 +1,7 @@
import React, { Fragment } from 'react';
import { Trans } from 'react-i18next';
import { R_IPV4 } from '../helpers/constants';
import { R_IPV4, UNSAFE_PORTS } from '../helpers/constants';
export const renderField = ({
input, id, className, placeholder, type, disabled, meta: { touched, error },
@@ -69,4 +69,11 @@ export const port = (value) => {
return false;
};
export const isSafePort = (value) => {
if (UNSAFE_PORTS.includes(value)) {
return <Trans>form_error_port_unsafe</Trans>;
}
return false;
};
export const toNumber = value => value && parseInt(value, 10);