Effect CommunityEC
Effect Community2y ago
5 replies
Jonathan Clem

Creating a Branded Type with Arbitrary ULID Generation

Can I have a branded type that also has an arbitrary value generator?

Basically I want this to generate ULIDs:
export type MyID = typeof S.ULID.Type & Brand.Brand<"MyID">;
export const MyID = Brand.nominal<MyID>();

What I don't want is to run the ULID regex on these many many values that I know have valid ULIDs, which is why I'm not using just S.ULID itself. The branded type is useful, though.
Was this page helpful?