Type Parameters

  • T

Hierarchy

  • Codec

Properties

decode: ((input) => functional.Either<string, T>)

Type declaration

    • (input): functional.Either<string, T>
    • Takes a JSON value and runs the decode function the codec was constructed with. All of purify's built-in codecs return a descriptive error message in case the decode fails

      Parameters

      • input: unknown

      Returns functional.Either<string, T>

encode: (<U>(input) => U)

Type declaration

    • <U>(input): U
    • Takes a runtime value and turns it into a JSON value using the encode function the codec was constructed with. Most of purify's built-in codecs have no custom encode method and they just return the same value, but you could add custom serialization logic for your custom codecs.

      Type Parameters

      • U = unknown

      Parameters

      • input: T

      Returns U

schema: (() => JSONSchema6)

Type declaration

    • (): JSONSchema6
    • Returns JSONSchema6

unsafeDecode: ((input) => T)

Type declaration

    • (input): T
    • The same as the decode method, but throws an exception on failure. Please only use as an escape hatch

      Parameters

      • input: unknown

      Returns T

Generated using TypeDoc