Local modifications to ClusterLabs/Anvil by Alteeve
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.
|
|
|
import { REP_IPV4 } from '../consts/REG_EXP_PATTERNS';
|
|
|
|
|
|
|
|
const buildIPAddressTestBatch: BuildInputTestBatchFunction = (
|
|
|
|
inputName,
|
|
|
|
onSuccess,
|
|
|
|
{ isRequired, onFinishBatch, ...defaults } = {},
|
|
|
|
onIPv4TestFailure,
|
|
|
|
) => ({
|
|
|
|
defaults: { ...defaults, onSuccess },
|
|
|
|
isRequired,
|
|
|
|
onFinishBatch,
|
|
|
|
tests: [
|
|
|
|
{
|
|
|
|
onFailure: (...args) => {
|
|
|
|
onIPv4TestFailure(
|
|
|
|
`${inputName} should be a valid IPv4 address.`,
|
|
|
|
...args,
|
|
|
|
);
|
|
|
|
},
|
|
|
|
test: ({ value }) => REP_IPV4.test(value as string),
|
|
|
|
},
|
|
|
|
],
|
|
|
|
});
|
|
|
|
|
|
|
|
export default buildIPAddressTestBatch;
|