Skip to content

Commit 3f5b4dd

Browse files
Sir-JSergey Rogachev
andauthored
fix: async validator work (#84)
* fix: async validator work Fix async validator work in conjunction with Validators.required * fix: remove empty pipe Co-authored-by: Sergey Rogachev <[email protected]>
1 parent 8a037e2 commit 3f5b4dd

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

projects/ngneat/error-tailor/src/lib/control-error.directive.spec.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ describe('ControlErrorDirective', () => {
7979
ignored: ['', Validators.required],
8080
explicit: [''],
8181
names: this.builder.array([this.createName(), this.createName()], this.validator),
82-
username: ['', null, this.usernameValidator.bind(this)],
82+
username: ['', Validators.required, this.usernameValidator.bind(this)],
8383
onSubmitOnly: ['', [Validators.required]],
8484
onEveryChange: ['', [Validators.required]]
8585
});
@@ -123,6 +123,8 @@ describe('ControlErrorDirective', () => {
123123

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

127129
typeInElementAndFocusOut(spectator, 't', nameInput);
128130

projects/ngneat/error-tailor/src/lib/control-error.directive.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ export class ControlErrorsDirective implements OnInit, OnDestroy {
9191

9292
if (this.mergedConfig.controlErrorsOn.async && hasAsyncValidator) {
9393
// hasAsyncThenUponStatusChange
94-
changesOnAsync$ = statusChanges$.pipe(startWith(true));
94+
changesOnAsync$ = statusChanges$;
9595
}
9696

9797
if (this.isInput && this.mergedConfig.controlErrorsOn.change) {

0 commit comments

Comments
 (0)