You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
26 lines
640 B
26 lines
640 B
2 years ago
|
import { REP_IPV4_CSV } from '../consts/REG_EXP_PATTERNS';
|
||
|
|
||
|
const buildIpCsvTestBatch: BuildInputTestBatchFunction = (
|
||
|
inputName,
|
||
|
onSuccess,
|
||
|
{ isRequired, onFinishBatch, ...defaults } = {},
|
||
|
onIpCsvTestFailure,
|
||
|
) => ({
|
||
|
defaults: { ...defaults, onSuccess },
|
||
|
isRequired,
|
||
|
onFinishBatch,
|
||
|
tests: [
|
||
|
{
|
||
|
onFailure: (...args) => {
|
||
|
onIpCsvTestFailure(
|
||
|
`${inputName} must be one or more valid IPv4 addresses separated by comma; without trailing comma.`,
|
||
|
...args,
|
||
|
);
|
||
|
},
|
||
|
test: ({ value }) => REP_IPV4_CSV.test(value as string),
|
||
|
},
|
||
|
],
|
||
|
});
|
||
|
|
||
|
export default buildIpCsvTestBatch;
|