@traversable/schema
    Preparing search index...
    • Given a JSON Schema spec, returns a predicate function that accepts any input and returns a boolean indicating whether the input satisfied the spec.

      Note:

      See also:

      Type Parameters

      • T extends F<unknown>

      Parameters

      • schema: T

      Returns (x: unknown) => boolean

      import { check } from '@traversable/json-schema-types'

      const myCheck = check({ type: 'boolean' })

      console.log(myCheck(false)) // => true
      console.log(myCheck('true')) // => false

      const myTypeGuard = check({ type: 'boolean' }, { asTypeGuard: true })

      declare const input: unknown

      if (myTypeGuard(input)) {
      input
      // ^? const input: boolean
      }
    • Given a JSON Schema spec, returns a predicate function that accepts any input and returns a boolean indicating whether the input satisfied the spec.

      Note:

      See also:

      Type Parameters

      • const T extends F<unknown>

      Parameters

      Returns (x: unknown) => x is toType<T>

      import { check } from '@traversable/json-schema-types'

      const myCheck = check({ type: 'boolean' })

      console.log(myCheck(false)) // => true
      console.log(myCheck('true')) // => false

      const myTypeGuard = check({ type: 'boolean' }, { asTypeGuard: true })

      declare const input: unknown

      if (myTypeGuard(input)) {
      input
      // ^? const input: boolean
      }