© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
Drizzle TeamDT
Drizzle Team•2y ago•
2 replies
textYash

How to check schema fields against a regex?

I want to restrict the usernames in my user table with a regex. Basically instagram like criteria for usernames.
This is my current schema:
username: varchar('username', { length: 128 }).unique().notNull(),
username: varchar('username', { length: 128 }).unique().notNull(),

Is there any method that I can call on this to restrict the username? Something like this:
username: varchar('username', { length: 64 }).unique().notNull()./^(?!.*\.\.)(?!.*\.$)[^\W][\w.]{0,64}$/igm.test(email),
username: varchar('username', { length: 64 }).unique().notNull()./^(?!.*\.\.)(?!.*\.$)[^\W][\w.]{0,64}$/igm.test(email),

I know that's nonsense code above, but I'm just trying to convey myself. please don't mind 😅
Drizzle TeamJoin
The official Discord for all Drizzle related projects, such as Drizzle ORM, Drizzle Kit, Drizzle Studio and more!
11,879Members
Resources

Similar Threads

Was this page helpful?
Recent Announcements

Similar Threads

RQB | using specific fields from a query against relations
Drizzle TeamDTDrizzle Team / help
3y ago
How to check for non-backwards compatible schema changes
Drizzle TeamDTDrizzle Team / help
2y ago
[drizzle-zod] How to make all fields of a schema derived from a table required ?
Drizzle TeamDTDrizzle Team / help
3y ago
How to implement a 'check' constraint
Drizzle TeamDTDrizzle Team / help
3y ago