All files String.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 16x 8x     8x 8x   1x  
import { nonEmptyArray } from 'fp-ts/lib/NonEmptyArray';
import * as ValidationFn from 'fp-ts/lib/Validation';
 
import Decoder, { Decoded } from './Decoder';
 
export default class StringD extends Decoder<string> {
  public run(value: unknown): Decoded<string> {
    if (typeof value === 'string') {
      return ValidationFn.success(value);
    }
 
    const message = `Value must be a string, found "${typeof value}" instead`;
    return ValidationFn.failure(nonEmptyArray.of(message));
  }
}