Skip to content

Commit c655352

Browse files
committed
user profile settings: support full names with more than 2 words, require full name to have at least 2 words
1 parent 8660c2a commit c655352

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

src/routes/settings/helpers/settings.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,8 @@ export const applyProfileSettingsToTraits = (traits, profileSettings) => {
111111
// to the `basic_info` we put just photoUrl, firstName and lastName
112112
if (trait.traitId === 'basic_info') {
113113
const updatedTrait = {...trait}
114-
const [firstName, lastName] = profileSettings.firstNLastName ? profileSettings.firstNLastName.split(/\s+/) : []
114+
// get first and last name, if don't have should return `undefined`
115+
const [, firstName, lastName] = profileSettings.firstNLastName ? profileSettings.firstNLastName.match(/([^\s]+)\s*(.*)/) : []
115116
const photoURL = profileSettings.photoUrl
116117
const country = profileSettings.country
117118

src/routes/settings/routes/profile/components/ProfileSettingsForm.jsx

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,11 @@ class ProfileSettingsForm extends Component {
4242
validations = {
4343
matchRegexp: /^([+]?\d{1,2}[.-\s]?)?(\d{3}[.-]?){2}\d{4}$/
4444
}
45+
} else if (name === 'firstNLastName') {
46+
validations = {
47+
// should have first and last name
48+
matchRegexp: /(.+)\s+(.+)/
49+
}
4550
}
4651
return (
4752
<div className="field">

0 commit comments

Comments
 (0)