shapeit
Version:
Object validation tools for Javascript and, specially, Typescript
16 lines (15 loc) • 423 B
TypeScript
import { FromPrimitive, Primitive } from '../types/utils';
/**
* Basic Guard creator from a primitive name.
*
* @example
* const isString = is('string');
*
* if (isString(value)) {
* doSomethingWith(value); // value is typed as string
* }
* else {
* console.error(isString.errors); // Errors found
* }
*/
export default function is<T extends Primitive>(target: T): import("..").Guard<FromPrimitive<T>>;