1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 | 1x 1x 1x 1x 1x 21x 13x 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 NumberD extends Decoder<number> { public run(value: unknown): Decoded<number> { if (typeof value === 'number') { return ValidationFn.success(value); } const message = `Value must be a number, found "${typeof value}" instead`; return ValidationFn.failure(nonEmptyArray.of(message)); } } |