Skip to content

Commit

Permalink
fix: async validator work (#84)
Browse files Browse the repository at this point in the history
* fix: async validator work

Fix async validator work in conjunction with Validators.required

* fix: remove empty pipe

Co-authored-by: Sergey Rogachev <[email protected]>
  • Loading branch information
Sir-J and Sergey Rogachev committed Sep 20, 2022
1 parent 8a037e2 commit 3f5b4dd
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ describe('ControlErrorDirective', () => {
ignored: ['', Validators.required],
explicit: [''],
names: this.builder.array([this.createName(), this.createName()], this.validator),
username: ['', null, this.usernameValidator.bind(this)],
username: ['', Validators.required, this.usernameValidator.bind(this)],
onSubmitOnly: ['', [Validators.required]],
onEveryChange: ['', [Validators.required]]
});
Expand Down Expand Up @@ -123,6 +123,8 @@ describe('ControlErrorDirective', () => {

it('should show errors on interactions', () => {
const nameInput = spectator.query<HTMLInputElement>(byPlaceholder('Name'));
const usernameInput = spectator.query<HTMLInputElement>(byPlaceholder('Username'));
typeInElementAndFocusOut(spectator, 'async', usernameInput);

typeInElementAndFocusOut(spectator, 't', nameInput);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ export class ControlErrorsDirective implements OnInit, OnDestroy {

if (this.mergedConfig.controlErrorsOn.async && hasAsyncValidator) {
// hasAsyncThenUponStatusChange
changesOnAsync$ = statusChanges$.pipe(startWith(true));
changesOnAsync$ = statusChanges$;
}

if (this.isInput && this.mergedConfig.controlErrorsOn.change) {
Expand Down

0 comments on commit 3f5b4dd

Please sign in to comment.