Decoder that only accepts a specific constant value.

const trueDecoder = JsonDecoder.constant(true);

trueDecoder.decode(true); // Ok<boolean>({value: true})
trueDecoder.decode(false); // Err({error: 'false is not exactly true'})
  • Type Parameters

    • T

    Parameters

    • value: T

      The constant value to accept

    Returns Decoder<T>

    A decoder that only accepts the specified value