Library update: ajv-ts 0.4

Table of contents

New Features

Now schema builder supports custom error messages.

import s from 'ajv-ts'

const num = s.number().error('cannot be not a number')

const res1 = num.safeParse("some random string")
const res2 = num.safeParse("1.2")
console.error(res1.error.message) // cannot be not a number
console.error(res2.error.message) // cannot be not a number

res1.error instanceof Error // true

Fixes

  • Issue with installation #21