How do I make username a required field during sign up?
// auth.ts
// schema.ts
When I call the sign up with email endpoint with this payload,
I get error from DB, "insert into users failed..." instead of better auth's error
8 Replies
When I add lastName as a required field, I do get errors if I don't send lastName
Why does it not work for username? 🙁
@Farhan you can pass schema configurations under the username plugin itself
@Max can you please give me an example or point to the docs?
not sure what to do here, there's no option to make it required

oh interesting... I'll see what I can do to fix
For now you should edit your DB schema to do this
If my PR lands then it will have built-in Better-Auth support for you to pass
required: true for the fields
https://github.com/better-auth/better-auth/pull/5330GitHub
feat: support custom field attributes in plugin schemas by ping-max...
In the auth config, you can define a user/session/account/etc schema to customize the field attributes in a given table.
Right now with plugin schemas, you can only customize the field name. With t...
@Farhan
Wow that's a very quick PR! Thank you!