ts.data.json - v4.1.0
    Preparing search index...

    Function literal

    • Decoder that only accepts a specific value.

      Type Parameters

      • const T

      Parameters

      • value: T

        The exact value to accept

      Returns Decoder<T>

      A decoder that only accepts the specified value

      const oneDecoder = JsonDecoder.literal(1);

      oneDecoder.decode(1); // Ok<1>({value: 1})
      oneDecoder.decode(2); // Err({ issues: [{ message: '2 is not exactly 1', path: [] }] })