Skip to content

Commit

Permalink
fix: 🐛 allows accented characters in name for existing users
Browse files Browse the repository at this point in the history
  • Loading branch information
shaheer-deriv committed Mar 8, 2023
1 parent 9ce7b7a commit 94c7ea8
Showing 1 changed file with 11 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -312,8 +312,6 @@ export const PersonalDetailsForm = ({
}

validateValues(val => val, required_fields, localize('This field is required'));
const only_alphabet_fields = ['first_name', 'last_name'];
validateValues(validLetterSymbol, only_alphabet_fields, localize('Only alphabet is allowed'));

const residence_fields = ['citizen'];
const validateResidence = val => getLocation(residence_list, val, 'value');
Expand Down Expand Up @@ -349,12 +347,17 @@ export const PersonalDetailsForm = ({

const min_name = 2;
const max_name = 50;
if (values.first_name && !validLength(values.first_name.trim(), { min: min_name, max: max_name })) {
errors.first_name = localize('You should enter 2-50 characters.');
}
if (values.last_name && !validLength(values.last_name.trim(), { min: min_name, max: max_name })) {
errors.last_name = localize('You should enter 2-50 characters.');
}
const validateName = (name, field) => {
if (name) {
if (!validLength(name.trim(), { min: min_name, max: max_name })) {
errors[field] = localize('You should enter 2-50 characters.');
} else if (!/^(?!.*\s{2,})[\p{L}\s'.-]{2,50}$/u.test(name)) {
errors[field] = localize('Letters, spaces, periods, hyphens, apostrophes only.');
}
}
};
validateName(values.first_name, 'first_name');
validateName(values.last_name, 'last_name');

if (values.phone) {
// minimum characters required is 9 numbers (excluding +- signs or space)
Expand Down

0 comments on commit 94c7ea8

Please sign in to comment.