-
Notifications
You must be signed in to change notification settings - Fork 25
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
sync businessPhone validation with member api #333
Comments
Here are all the validation rules from the Member Service: if (item.getFirstNLastName() == null || item.getFirstNLastName().trim().length() == 0) {
result.add("The first and last Name should be provided");
}
if (item.getBusinessEmail() != null && item.getBusinessEmail().trim().length() != 0) {
Pattern pattern = Pattern.compile("^[A-Z0-9._%+-]+@[A-Z0-9.-]+\\.[A-Z]{2,6}$", Pattern.CASE_INSENSITIVE);
if (!pattern.matcher(item.getBusinessEmail().trim()).matches()) {
result.add("The business email should be provided in correct format");
}
}
if (item.getBusinessPhone() != null && item.getBusinessPhone().trim().length() != 0) {
Pattern pattern = Pattern.compile("^\\+(?:[0-9] ?){6,14}[0-9]$");
if (!pattern.matcher(item.getBusinessPhone().trim()).matches()) {
result.add("The business phone should be provided in correct format");
}
}
if (item.getTitle() == null || item.getTitle().trim().length() == 0) {
result.add("The title should be provided");
}
if (item.getCompanyName() == null || item.getCompanyName().trim().length() == 0) {
result.add("The company name should be provided");
}
if (item.getCompanySize() == null || item.getCompanySize().trim().length() == 0) {
result.add("The company size should be provided");
} I guess the best we can do is:
|
I guess if we use the same regex as member api is using, we would be in safest position right? |
It would the easiest and safe solution. Our current validator is much more complicated than member service regexp. |
Go with that. |
Sum up:
To avoid the server-side issue when creating a user or update user details, we should make the validation rules for the phone number we have client-side, to be the same we have server-side:
|
@maxceem the code can only be changed in |
The code can be changed in all repositories including |
As of now user can enter phone number in a format which is not acceptable by the member api (trait endpoint) which causes the api to fail while trying to create user trait.
Request:
Response:
In this particular example, I guess, the issue is missing
+
as prefix of the business phone string.Ideally, our front end validation should have prevented user entering such value or automatically append the
+
.fyi @maxceem @RishiRajSahu
The text was updated successfully, but these errors were encountered: