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
Nameextendsstring
Example
typePercent=Brand<number, 'Percent'>;
functionpercent(value: number): Result<Percent, PercentIssue> { if (value<0||value>100) returnerr(PercentIssue.OutOfRange);
A
Basevalue that passed the check namedName. 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.