0.0.6 • Published 1 year ago
@typesafe-validator/test v0.0.6
@typesafe-validator/test
Validator test helper
Installation
pnpm add @typesafe-validator/test -D
Usage
import { expect, test } from 'vitest';
import { testOK, testFail, testOpenapi } from '@typesafe-validator/test';
expect('case1', async () => {
const validator = rule.myValidator();
await testOK(validator, [source1, source2]);
});
expect('case2', async () => {
const validator = rule.myValidator();
await testFail(validator, [source1, source2], 'should be my rule');
});
testOpenapi({
required: rule.myValidator(),
optional: rule.myValidator().optional(),
withDefault: rule.myValidator().optional().default(''),
withDocs: rule.myValidator(),
});