+ client: modify added filters

This commit is contained in:
Ildar Kamalov
2020-01-20 15:47:10 +03:00
committed by Simon Zolin
parent 0b8cba7384
commit b3bca39de4
8 changed files with 235 additions and 90 deletions

View File

@@ -1,7 +1,7 @@
import React, { Fragment } from 'react';
import { Trans } from 'react-i18next';
import PropTypes from 'prop-types';
import { R_IPV4, R_MAC, R_HOST, R_IPV6, R_CIDR, UNSAFE_PORTS } from '../helpers/constants';
import { R_IPV4, R_MAC, R_HOST, R_IPV6, R_CIDR, UNSAFE_PORTS, R_URL_REQUIRES_PROTOCOL } from '../helpers/constants';
import { createOnBlurHandler } from './helpers';
export const renderField = (props, elementType) => {
@@ -270,4 +270,11 @@ export const answer = (value) => {
return undefined;
};
export const isValidUrl = (value) => {
if (value && !R_URL_REQUIRES_PROTOCOL.test(value)) {
return <Trans>form_error_url_format</Trans>;
}
return undefined;
};
export const toNumber = value => value && parseInt(value, 10);