@@ -3,6 +3,7 @@ import {FormGroup, FormControl, Validators} from "@angular/forms";
3
3
import { ActivatedRoute } from "@angular/router" ;
4
4
import isEmpty from "lodash/isEmpty" ;
5
5
import omitBy from "lodash/omitBy" ;
6
+ import values from "lodash/values" ;
6
7
import { User } from "../../core/domains" ;
7
8
import { UserService } from "../../core/services/user.service" ;
8
9
import { EMAIL_PATTERN , Validators as AppValidators } from "../../core/forms" ;
@@ -35,8 +36,8 @@ export class UserEditComponent implements OnInit {
35
36
}
36
37
37
38
onSubmit ( params ) {
38
- this . passwordConfirmation . updateValueAndValidity ( { } ) ;
39
- this . passwordConfirmation . markAsTouched ( ) ;
39
+ values ( this . myForm . controls ) . forEach ( c => c . markAsTouched ( ) ) ;
40
+
40
41
if ( ! this . myForm . valid ) return ;
41
42
42
43
this . userService . updateMe ( omitBy ( params , isEmpty ) )
@@ -57,15 +58,13 @@ export class UserEditComponent implements OnInit {
57
58
this . password = new FormControl ( '' , Validators . compose ( [
58
59
Validators . minLength ( 8 ) ,
59
60
] ) ) ;
60
- this . passwordConfirmation = new FormControl ( '' , Validators . compose ( [
61
- AppValidators . match ( this . password ) ,
62
- ] ) ) ;
61
+ this . passwordConfirmation = new FormControl ( '' ) ;
63
62
this . myForm = new FormGroup ( {
64
63
name : this . name ,
65
64
email : this . email ,
66
65
password : this . password ,
67
66
passwordConfirmation : this . passwordConfirmation ,
68
- } ) ;
67
+ } , AppValidators . match ( this . password , this . passwordConfirmation ) ) ;
69
68
}
70
69
71
70
private handleError ( error ) {
0 commit comments