File tree Expand file tree Collapse file tree 1 file changed +16
-0
lines changed
src/shared/components/Settings/Profile/BasicInfo Expand file tree Collapse file tree 1 file changed +16
-0
lines changed Original file line number Diff line number Diff line change @@ -100,7 +100,9 @@ export default class BasicInfo extends ConsentComponent {
100
100
let invalid = false ;
101
101
let errorMessage = '' ;
102
102
let dateError = '' ;
103
+ let zipError = '' ;
103
104
let birthDateInvalid = false ;
105
+ let zipInvalid = false ;
104
106
const invalidFields = [ ] ;
105
107
106
108
if ( ! _ . trim ( newBasicInfo . firstName ) . length ) {
@@ -123,6 +125,13 @@ export default class BasicInfo extends ConsentComponent {
123
125
errorMessage += ' cannot be empty' ;
124
126
}
125
127
128
+ _ . forEach ( newBasicInfo . addresses , ( address ) => {
129
+ if ( ! ( / ^ [ 0 - 9 - ] * $ / . test ( address . zip ) ) ) {
130
+ zipError = 'You must enter a valid zip code' ;
131
+ zipInvalid = true ;
132
+ }
133
+ } ) ;
134
+
126
135
if ( _ . trim ( newBasicInfo . birthDate ) . length > 0 ) {
127
136
if ( ! moment ( ) . isAfter ( newBasicInfo . birthDate ) ) {
128
137
dateError = 'You must enter a valid date for Birth Date' ;
@@ -137,6 +146,13 @@ export default class BasicInfo extends ConsentComponent {
137
146
invalid = birthDateInvalid ;
138
147
}
139
148
149
+ if ( errorMessage . length > 0 ) {
150
+ errorMessage = `${ errorMessage } . ${ zipError } ` ;
151
+ } else if ( zipError . length > 0 ) {
152
+ errorMessage = zipError ;
153
+ invalid = zipInvalid ;
154
+ }
155
+
140
156
this . setState ( { errorMessage, formInvalid : invalid } ) ;
141
157
return invalid ;
142
158
}
You can’t perform that action at this time.
0 commit comments