validation
This commit is contained in:
@@ -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);
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user