#Is it possible to have a field in the User collection be required only for users with a certain role

11 messages · Page 1 of 1 (latest)

tawdry coral
#

I want users with the "customer" role to be required to fill in a phone number... but it should be optional for users without the "customer" role.

Below is our current User collection

halcyon vergeBOT
tawdry coral
sour breach
#

This should probably be achieveable with a field hook

#

I would try the ai help for this 🙂

tawdry coral
#

damn, I was hoping I could do without hooks. But I only need one hook even if I want to add it to multiple fields right?

#

Would be nice if we could do the same as we can with access:

access: {
  admin: ({ req: { user } }) => checkRole(["admin"], user),
}
sour breach
#

yeah, you could simplify it down to:

access: {
  admin: requiredForUser("admin")
}

by creating a field access function

#

but perhaps the hook is even more intuitive... because you can check for the value

#

and access also has influence on the api exposure of the field