API reference / @evolu/common / Type / BrandFactory
Type Alias: BrandFactory()<Name, Input, RefineError>
type BrandFactory<Name, Input, RefineError> = <PName, P, PInput, PParent, PError, PParentError>(parent) => BrandType<Type<PName, P, PInput, PError, PParent, PParentError>, Name, RefineError, PError | PParentError>;
Defined in: packages/common/src/Type.ts:896
Helper type for Type Factory that creates a branded Type.
Example
const trimmed: BrandFactory<"Trimmed", string, TrimmedError> = (
parent,
) =>
brand("Trimmed", parent, (value) =>
value.trim().length === value.length
? ok(value)
: err<TrimmedError>({ type: "Trimmed", value }),
);
Type Parameters
Type Parameter |
---|
Name extends TypeName |
Input |
RefineError extends TypeError |
Type Parameters
Type Parameter | Default type |
---|---|
PName extends TypeName | - |
P extends Input | - |
PInput | - |
PParent | - |
PError extends TypeError | never |
PParentError extends TypeError | never |
Parameters
Parameter | Type |
---|---|
parent | Type <PName , P , PInput , PError , PParent , PParentError > |
Returns
BrandType
<Type
<PName
, P
, PInput
, PError
, PParent
, PParentError
>, Name
, RefineError
, PError
| PParentError
>