• 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({error: '2 is not exactly 1'})