|
|
@ -7,3 +7,12 @@ test('not', t => { |
|
|
|
t.notThrows(() => m('foo!', m.string.not.alphanumeric)); |
|
|
|
t.throws(() => m('' as any, m.string.not.empty), '[NOT] Expected string to be empty, got ``'); |
|
|
|
}); |
|
|
|
|
|
|
|
test('reusable validator', t => { |
|
|
|
const checkUsername = m.create(m.string.minLength(3)); |
|
|
|
|
|
|
|
t.notThrows(() => checkUsername('foo')); |
|
|
|
t.notThrows(() => checkUsername('foobar')); |
|
|
|
t.throws(() => checkUsername('fo'), 'Expected string to have a minimum length of `3`, got `fo`'); |
|
|
|
t.throws(() => checkUsername(5 as any), 'Expected argument to be of type `string` but received type `number`'); |
|
|
|
}); |
|
|
|