parent
caa63c4535
commit
4781a5a158
4 changed files with 37 additions and 1 deletions
@ -0,0 +1,23 @@ |
|||||||
|
import { REP_UUID } from '../consts/REG_EXP_PATTERNS'; |
||||||
|
|
||||||
|
import testNotBlank from './testNotBlank'; |
||||||
|
|
||||||
|
const buildUUIDTestBatch: BuildInputTestBatchFunction = ( |
||||||
|
inputName, |
||||||
|
onSuccess, |
||||||
|
{ getValue } = {}, |
||||||
|
onUUIDTestFailure, |
||||||
|
) => ({ |
||||||
|
defaults: { getValue, onSuccess }, |
||||||
|
tests: [ |
||||||
|
{ |
||||||
|
onFailure: (...args) => { |
||||||
|
onUUIDTestFailure(`${inputName} must be a valid UUID.`, ...args); |
||||||
|
}, |
||||||
|
test: ({ value }) => REP_UUID.test(value as string), |
||||||
|
}, |
||||||
|
{ test: testNotBlank }, |
||||||
|
], |
||||||
|
}); |
||||||
|
|
||||||
|
export default buildUUIDTestBatch; |
Loading…
Reference in new issue