Documentation
Coverage

Coverage

TypeSchema supports all major schema validation libraries:

ProjectPopularitywrapvalidateassertInferInferInExample schema
zod (opens in a new tab)GitHub starsz.string()
yup (opens in a new tab)GitHub starsstring()
joi (opens in a new tab)GitHub starsJoi.string()
ajv (opens in a new tab)GitHub stars{type: "string"}
superstruct (opens in a new tab)GitHub starsstring()
io-ts (opens in a new tab)GitHub starst.string
ow (opens in a new tab) (^0.28.2)GitHub starsow.string
typia (opens in a new tab)GitHub starstypia.createAssert<string>()
valibot (opens in a new tab)GitHub starsstring()
typebox (opens in a new tab)GitHub starsType.String()
deepkit (opens in a new tab)GitHub starstypeOf<string>()
effect (opens in a new tab)GitHub starsS.string
runtypes (opens in a new tab)GitHub starsString
arktype (opens in a new tab)GitHub starstype('string')

Custom validations are also supported:

export function assertString(data: unknown): string {
  if (typeof data !== 'string') {
    throw new Error('Expected a string, got: ' + data);
  }
  return data;
}
 
await validate(assertString, '123'); // {data: '123'}
await validate(assertString, 123); // {issues: [`ValidationIssue`]}
 
await assert(assertString, '123'); // '123'
await assert(assertString, 123); // throws `AggregateError`