Revisions
-
nicobytes revised this gist
Apr 12, 2020 . 1 changed file with 8 additions and 0 deletions.There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -47,4 +47,12 @@ validateEmail(control: AbstractControl) { }) ); } ``` ### html ```html <p class="help is-danger" *ngIf="emailField.hasError('notAvailable')"> Es correo esta ocupado </p> ``` -
nicobytes revised this gist
Apr 12, 2020 . 1 changed file with 14 additions and 0 deletions.There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -33,4 +33,18 @@ static validateEmail(userService: UserService) { ); }; } ``` ```ts validateEmail(control: AbstractControl) { const value = control.value; return this.userService.checkEmail(value) .pipe( map(response => { const isEmailAvailable = response.isEmailAvailable; return isEmailAvailable ? null : {notAvailable: true}; }) ); } ``` -
nicobytes revised this gist
Apr 12, 2020 . 1 changed file with 19 additions and 0 deletions.There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,3 +1,5 @@ ## service ```ts @Injectable({ providedIn: 'root' @@ -14,4 +16,21 @@ export class UserService { .pipe(delay(500)); } } ``` ## validations ```ts static validateEmail(userService: UserService) { return (control: AbstractControl) => { const value = control.value; return userService.checkEmail(value) .pipe( map(response => { const isEmailAvailable = response.isEmailAvailable; return isEmailAvailable ? null : {notAvailable: true}; }) ); }; } ``` -
nicobytes created this gist
Apr 12, 2020 .There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,17 @@ ```ts @Injectable({ providedIn: 'root' }) export class UserService { constructor( private http: HttpClient ) { } checkEmail(email: string) { // simulate http.get() return of({ isEmailAvailable: email !== 'nicolas@gmail.com'}) .pipe(delay(500)); } } ```