parent
fea0657119
commit
16ac5a4e6d
3 changed files with 59 additions and 1 deletions
@ -0,0 +1,25 @@ |
|||||||
|
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; |
Loading…
Reference in new issue