Email Validation

Hello, I am trying to fix our registerUser function. We need it so the user does not need to enter their email. We cannot let the email property be null because it causes issues to our front end. I would like to add a blank string (“”) to the email property if the user does not provide an email. The issue is that I keep getting a “400 - Provided email has wrong format. (3040)” error. I currently do not validate the email using a custom validator or validate within our code. Can someone help me?

APP ID: DD9FC30D-3A6F-AB4C-FF9C-24DC92E73100

1 Like

Hello @Noah_Caldwell!

You can change the identity from email to name in the Table Editor, for example:

And change the accepted parameters in the registerUser function:

Regards,
Alexander

Hello Alexander,

I am working with Noah on this same issue. We already have the identity set to phone instead of email so I don’t think that is causing the issue. Is there a default email validator within Backendless that we are missing? I tried to add a custom regEx validator to the email column in schema to accept an empty string. (something like: ^$|^[a-zA-Z0-9._%±]+@[a-zA-Z0-9.-]+.[a-zA-Z]{2,}$) but that did not work either.

Hello @Will_York!

For the email column in the Users table, the server will expect a valid email or null (even if you changed the validator in the console).

Regards,
Alexander

That goes back to our initial question. Is there anyway to change this to accept an empty string? Our front end app cannot read the null values that Backendless sends. We have tried to handle these nulls values via the eventhandlers but it did not effect data being passed through Cloud Code API’s.

Unfortunately, no, for this column in the Users table the server will expect a valid email or null.

And what exactly is the difficulty in handling null?

Regards,
Alexander

Thanks for the info. Our previous backend provider would send empty strings to the front end (iOS/Android) when there was no value. This is what our frontend is used to handling and the Backendless ‘null’ value causes our front end to crash. We are trying to find a fix for this on the backend to minimize front end changes.

Our application does not require users to enter their email which is why we are facing this issue.

This can be handled in an “afterFind” event handler for the Users table. You could use some special value for emails in the DB and substitute that value with an empty string in the event handler.

1 Like