Type alias ParsingResult<T>

ParsingResult<T>: {
    invalidReason?: T;
    invalidReasonMessage?: string;
    valid: boolean;
}

Whereas ParsingError is thrown when parsing fails, e.g. in a fromString function, this type is returned from "defensive" functions like isValid.

Type Parameters

  • T

Type declaration

  • Optional invalidReason?: T

    If valid is false, this will be a code explaining why parsing failed.

  • Optional invalidReasonMessage?: string

    If valid is false, this will be a string explaining why parsing failed.

  • valid: boolean

    True if valid, false otherwise.