validation

This commit is contained in:
2018-04-25 20:12:10 -04:00
parent 5db5cf17e1
commit 0e4ceac959
8 changed files with 12 additions and 111 deletions

View File

@@ -4,21 +4,18 @@ import { RegistrationService } from '../registration.service';
@Injectable()
export class UsernameValidator {
debouncer: any;
constructor(
private registrationService: RegistrationService
){ }
constructor(private registrationService: RegistrationService){
}
checkUsername(control: FormControl): any {
checkUsername( control: FormControl ): any{
clearTimeout(this.debouncer);
return new Promise(resolve => {
this.debouncer = setTimeout(() => {
this.registrationService.validateUserName(control.value).subscribe((res) => {
if(res.ok){
resolve(null);
@@ -26,10 +23,7 @@ export class UsernameValidator {
}, (err) => {
resolve({'usernameInUse': true});
});
}, 1000);
});
}
}