StoicWanderer
StoicWanderer16mo ago

Serial number type

Hello Convex users, i have a simple question about using union type in Convex, would it make sense to use a union if i want to create a serialnumber for my users in the following format: #1987, like a string and number union?
2 Replies
Indy
Indy16mo ago
If you want the '#' in the string then the whole thing will have to be the string. If you don't, I recommend just using a number and add '#' whenever you visually present it in your ui. Unions in the Convex validators behave like typescript unions: https://www.typescriptlang.org/docs/handbook/2/everyday-types.html#union-types
Documentation - Everyday Types
The language primitives.
StoicWanderer
StoicWandererOP16mo ago
Oh too bad, but that's not a problem, i will use just as string and then add the hash later. Thank you for the info

Did you find this page helpful?