All files Boolean.ts

100% Statements 11/11
100% Branches 2/2
100% Functions 2/2
100% Lines 10/10
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 161x 1x   1x   1x 1x 14x 7x     7x 7x   1x  
import { nonEmptyArray } from 'fp-ts/lib/NonEmptyArray';
import * as ValidationFn from 'fp-ts/lib/Validation';
 
import Decoder, { Decoded } from './Decoder';
 
export default class BooleanD extends Decoder<boolean> {
  public run(value: unknown): Decoded<boolean> {
    if (typeof value === 'boolean') {
      return ValidationFn.success(value);
    }
 
    const message = `Value must be a boolean, found "${typeof value}" instead`;
    return ValidationFn.failure(nonEmptyArray.of(message));
  }
}