Skip to content
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

fix: ✨ allows users to enter accented name characters #7832

Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
Show all changes
16 commits
Select commit Hold shift + click to select a range
67d531f
fix: :sparkles: allows users to enter accented name characters
shaheer-deriv Mar 7, 2023
4bbe640
chore: :wastebasket: removes unused 'letter_symbol' variable
shaheer-deriv Mar 8, 2023
9ce7b7a
Merge branch 'binary-com:master' into shaheer/90186/last-name-input-v…
shaheer-deriv Mar 8, 2023
94c7ea8
fix: :bug: allows accented characters in name for existing users
shaheer-deriv Mar 8, 2023
0d1bf15
Merge branch 'binary-com:master' into shaheer/90186/last-name-input-v…
shaheer-deriv Mar 9, 2023
bc44028
Merge branch 'binary-com:master' into shaheer/90186/last-name-input-v…
shaheer-deriv Mar 13, 2023
8ff10d7
Merge branch 'binary-com:master' into shaheer/90186/last-name-input-v…
shaheer-deriv Mar 14, 2023
d78d579
Merge branch 'binary-com:master' into shaheer/90186/last-name-input-v…
shaheer-deriv Mar 15, 2023
7b571bf
Merge branch 'master' into shaheer/90186/last-name-input-validation
shaheer-deriv Mar 15, 2023
fd27880
docs: :pencil2: comment on the regex used for name validation
shaheer-deriv Mar 15, 2023
20e0d2a
resused regex function
shaheer-deriv Mar 16, 2023
449e5bf
Merge branch 'master' into shaheer/90186/last-name-input-validation
shaheer-deriv Mar 16, 2023
c5afae2
fix: :memo: imported reused regex function
shaheer-deriv Mar 16, 2023
de4037d
Merge branch 'master' into shaheer/90186/last-name-input-validation
shaheer-deriv Mar 16, 2023
b2d392c
fix: :memo: comment on regex function used
shaheer-deriv Mar 16, 2023
ef6e34d
Merge branch 'master' into shaheer/90186/last-name-input-validation
shaheer-deriv Mar 17, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions packages/account/src/Configs/personal-details-config.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ const personal_details_config = ({ residence_list, account_settings, is_appstore
rules: [
['req', localize('First name is required.')],
['length', localize('First name should be between 2 and 50 characters.'), { min: 2, max: 50 }],
['letter_symbol', getErrorMessages().letter_symbol()],
['name', getErrorMessages().name()],
],
},
last_name: {
Expand All @@ -38,7 +38,7 @@ const personal_details_config = ({ residence_list, account_settings, is_appstore
rules: [
['req', localize('Last name is required.')],
['length', localize('Last name should be between 2 and 50 characters.'), { min: 2, max: 50 }],
['letter_symbol', getErrorMessages().letter_symbol()],
['name', getErrorMessages().name()],
],
},
date_of_birth: {
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/Constants/form-error-messages.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ export const FORM_ERROR_MESSAGES = {
}),
email: () => localize('Invalid email address.'),
general: () => localize('Only letters, numbers, space, hyphen, period, and apostrophe are allowed.'),
letter_symbol: () => localize('Letters, spaces, periods, hyphens, apostrophes only'),
name: () => localize('Letters, spaces, periods, hyphens, apostrophes only.'),
password: () => localize('Password should have lower and uppercase English letters with numbers.'),
po_box: () => localize('P.O. Box is not accepted in address'),
phone: () => localize('Please enter a valid phone number (e.g. +15417541234).'),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ export const validPostCode = (value: string) => value === '' || /^[A-Za-z0-9][A-
export const validTaxID = (value: string) => /(?!^$|\s+)[A-Za-z0-9./\s-]$/.test(value);
export const validPhone = (value: string) => /^\+?([0-9-]+\s)*[0-9-]+$/.test(value);
export const validLetterSymbol = (value: string) => /^[A-Za-z]+([a-zA-Z.' -])*[a-zA-Z.' -]+$/.test(value);
export const validName = (value: string) => /^(?!.*\s{2,})[\p{L}\s'.-]{2,50}$/u.test(value);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the same regex as the above. reuse the validName function in personal-details.jsx

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks @yashim-deriv. your change is committed to the code.

export const validLength = (value = '', options: TOptions) =>
(options.min ? value.length >= options.min : true) && (options.max ? value.length <= options.max : true);
export const validPassword = (value: string) => /(?=.*[a-z])(?=.*[A-Z])(?=.*\d)[a-zA-Z\d]+/.test(value);
Expand Down Expand Up @@ -108,9 +109,9 @@ const initPreBuildDVRs = () => ({
message: form_error_messages.general,
},
length: { func: validLength, message: '' }, // Message will be set in validLength function on initiation
letter_symbol: {
func: validLetterSymbol,
message: form_error_messages.letter_symbol,
name: {
func: validName,
message: form_error_messages.name,
},
number: {
func: (...args: [string, TOptions, Record<string, string | boolean>]) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ export type TFormErrorMessagesTypes = Record<
| 'barrier'
| 'email'
| 'general'
| 'letter_symbol'
| 'name'
| 'password'
| 'po_box'
| 'phone'
Expand Down