Tiva
🤧 EXPENSIVE plain object type validator leverages TypeScript language service.
Usage
yarn add tiva
import {Tiva} from 'tiva';
let tiva = new Tiva();
tiva.validate('string[]', ['foo', 'bar']).then(console.info, console.error);
tiva
.validate(
{module: 'module-specifier', type: 'AwesomeType'},
{foo: 'abc', bar: 123},
)
.then(console.info, console.error);
Extensions
Tiva can validate with extended validator functions that matches by @tag
in JSDoc comments:
interface Foo {
id: string;
}
There are a few built-in extensions:
@pattern <pattern>
Validate by regular expression pattern.@uuid [version]
UUID.@unique [group]
Validate that there's no more than one occurrence.
Checkout @built-in-extensions.ts for implementation details.
Custom extensions can be provided by options.extensions
of Tiva
constructor.
License
MIT License.