validate-{TS}
The object validator for TypeScript.

Install
npm install @mironal/validate-ts
Usage
interface Example {
n: number
s: string
b: boolean
obj: { [key: string]: string }
nested: { [key: string]: { [inner: string]: number[] } }
}
const validator = createValidatorFor<Example>({
n: value => typeof value === "number",
s: value => typeof value === "string",
b: value => typeof value === "boolean",
obj: value => typeof value === "object",
nested: value => typeof value === "object",
})
const anyVal = {}
try {
if (validator(anyVal)) {
}
} catch (e) {
console.error(e)
}
Recommended to use
We recommend that you use @sindresorhus/is to write validator more easily.
const is = require('@sindresorhus/is')
const validator = createValidatorFor<Example>({
n: value => is.number,
s: value => is.string,
b: value => is.boolean
obj: value => is.object,
nested: value => is.object,
})
TODO