@traversable/schema
    Preparing search index...
    • Derive a "deep equal" function from a valibot schema.

      A "deep equal" function" (see also, Equal) is similar to lodash's isEqual function, except more performant, because when the shape of the values being compared is known ahead of time, we can optimize ahead of time, and only check what's necessary.

      Note that the deep equal generated by vx.deepEqual assumes that both values have already been validated. Passing unvalidated values to the function might result in undefined behavior.

      See also:

      Type Parameters

      • T extends BaseSchema<any, any, any>

      Parameters

      • schema: T

      Returns Type.Equal<InferOutput<T>>

      import * as v from 'valibot'
      import { vx } from '@traversable/valibot'

      const deepEqual = vx.deepEqual(
      v.object({
      street1: v.string(),
      street2: v.optional(v.string()),
      city: v.string()
      })
      )

      deepEqual(
      { street1: '221B Baker St', city: 'London' },
      { street1: '221B Baker St', city: 'London' }
      ) // => true

      deepEqual(
      { street1: '221B Baker St', city: 'London' },
      { street1: '4 Privet Dr', city: 'Little Whinging' }
      ) // => false