@@ -3,6 +3,7 @@ import {FormGroup, FormControl, Validators} from "@angular/forms";
33import { ActivatedRoute } from "@angular/router" ;
44import isEmpty from "lodash/isEmpty" ;
55import omitBy from "lodash/omitBy" ;
6+ import values from "lodash/values" ;
67import { User } from "../../core/domains" ;
78import { UserService } from "../../core/services/user.service" ;
89import { EMAIL_PATTERN , Validators as AppValidators } from "../../core/forms" ;
@@ -35,8 +36,8 @@ export class UserEditComponent implements OnInit {
3536 }
3637
3738 onSubmit ( params ) {
38- this . passwordConfirmation . updateValueAndValidity ( { } ) ;
39- this . passwordConfirmation . markAsTouched ( ) ;
39+ values ( this . myForm . controls ) . forEach ( c => c . markAsTouched ( ) ) ;
40+
4041 if ( ! this . myForm . valid ) return ;
4142
4243 this . userService . updateMe ( omitBy ( params , isEmpty ) )
@@ -57,15 +58,13 @@ export class UserEditComponent implements OnInit {
5758 this . password = new FormControl ( '' , Validators . compose ( [
5859 Validators . minLength ( 8 ) ,
5960 ] ) ) ;
60- this . passwordConfirmation = new FormControl ( '' , Validators . compose ( [
61- AppValidators . match ( this . password ) ,
62- ] ) ) ;
61+ this . passwordConfirmation = new FormControl ( '' ) ;
6362 this . myForm = new FormGroup ( {
6463 name : this . name ,
6564 email : this . email ,
6665 password : this . password ,
6766 passwordConfirmation : this . passwordConfirmation ,
68- } ) ;
67+ } , AppValidators . match ( this . password , this . passwordConfirmation ) ) ;
6968 }
7069
7170 private handleError ( error ) {
0 commit comments