The concept is straightforward. A user inputs a string and I want to validate it. While I successfully implemented validation using SetTimeout and if/else logic, I am curious about how pipe/map can enhance this process.
Here is my current approach, but instead of only test2
being flagged as invalid, my name is always marked as invalid. There might be a mistake in my logic somewhere.
asyncInvalidProjectName(control: FormControl): Promise<any> | Observable<any> {
return of(control.value).pipe(
map(value => value === 'test2' ? { 'invalidProjectName': true } : null),
delay(500)
);
}