Skip to content

Commit e7505e6

Browse files
author
Maksym Mykhailenko
committed
fix: user profile form
Required fields should accept whitespaces ref issue #3833
1 parent 0e93aa2 commit e7505e6

File tree

1 file changed

+10
-12
lines changed

1 file changed

+10
-12
lines changed

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

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -119,23 +119,21 @@ class ProfileSettingsForm extends Component {
119119
}
120120

121121
getField(label, name, isRequired = false, isDisabled = false) {
122-
let validations = null
123-
let validationErrors
122+
const validations = {}
123+
const validationErrors = {}
124+
125+
if (isRequired) {
126+
validations.isRequired = true
127+
}
124128

125129
if (name === 'businessPhone') {
126-
validations = {
127-
// use same regexp as on server side
128-
matchRegexp: /^\+(?:[0-9] ?){6,14}[0-9]$/,
129-
}
130+
// use same regexp as on server side
131+
validations.matchRegexp = /^\+(?:[0-9] ?){6,14}[0-9]$/
130132
}
131133

132134
if (name === 'businessEmail') {
133-
validations = {
134-
isEmail: true,
135-
}
136-
validationErrors = {
137-
isEmail: 'Please, enter correct email'
138-
}
135+
validations.isEmail = true
136+
validationErrors.isEmail = 'Please, enter correct email'
139137
}
140138

141139
return (

0 commit comments

Comments
 (0)