TOC Toolkit API - v0.1.0
    Preparing search index...

    Type Alias Brand<Base, Name>

    Brand: Base & { "[brand]": Name }

    A Base value that passed the check named Name. A branded value is used wherever its base type is expected. A place that expects the brand rejects a plain base value and a value of another brand.

    A brand has one constructor, in the module that declares the brand. The constructor checks the base value and holds the only type assertion to the brand, so every branded value has passed the check.

    Type Parameters

    • Base
    • Name extends string
    type Percent = Brand<number, 'Percent'>;

    function percent(value: number): Result<Percent, PercentIssue> {
    if (value < 0 || value > 100) return err(PercentIssue.OutOfRange);

    return ok(value as Percent);
    }