Loading page…
Loading page…
Keep runtime checks aligned with your existing TypeScript object types.
Refine values, validate exhaustive unions, and safely handle unknown input.
pnpm add is-kit
import {and,isNumber,isString,not,or,predicateToRefine} from 'is-kit';const isShort = predicateToRefine<string>((s) => s.length <= 3);const isShortString = and(isString, isShort);isShortString('ok'); // trueisShortString('toolong'); // falseor(isString, isNumber)('x'); // truenot(isString)(42); // true
Build runtime guards around the TypeScript object types you already have. typedStruct<T>() helps keep runtime validation aligned when those types change.