Adding new field in class user

Hi There,

I just want to ask if possible to add a new field in the user class with duplicate entry validation.
Basically, I want to achieve I want to create a user registration and add a new field something like a telephone number. And during registration, I want to check if the telephone number already exists. If yes registration will fail and there will be a error code that says the telephone number is duplicated, Is that possible?

Warm Regards

I would expect it to be possible to add another field in User class.

you can try to use:

user.set("field_name", value)

but you’ll have to use a cloud function to check if it is duplicate and also to use beforeSave hook

Cool, do you have the specific docs for the cloud function to check if the new field_name is duplicate?

you can do a query in that cloud function to check if an entry with that value is present, the query is the same as in normal front end code, the difference is that you can use master key parameter:


1 Like

Thank you, Will try this one.