• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

atinc / ngx-tethys / #55

30 Jul 2025 07:08AM UTC coverage: 9.866% (-80.4%) from 90.297%
#55

push

why520crazy
feat(empty): add setMessage for update display text #TINFR-2616

92 of 6794 branches covered (1.35%)

Branch coverage included in aggregate %.

2014 of 14552 relevant lines covered (13.84%)

6.15 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

15.79
/src/form/validator/unique-validator.directive.ts
1
import { AsyncValidator, AbstractControl, ValidationErrors, NG_ASYNC_VALIDATORS } from '@angular/forms';
2
import { Directive, ElementRef, inject, input } from '@angular/core';
3
import { Observable, of } from 'rxjs';
4
import { map, catchError } from 'rxjs/operators';
5
import { ThyFormDirective } from '../form.directive';
6

7
/**
8
 * 用于校验表单控件的输入值是否已经存在
9
 * @name thyUniqueCheck
10
 * @order 20
11
 */
12
@Directive({
13
    selector: '[thyUniqueCheck]',
1✔
14
    providers: [{ provide: NG_ASYNC_VALIDATORS, useExisting: ThyUniqueCheckValidator, multi: true }]
15
})
×
16
export class ThyUniqueCheckValidator implements AsyncValidator {
×
17
    private elementRef = inject(ElementRef);
×
18
    private thyForm = inject(ThyFormDirective, { optional: true })!;
19

20
    readonly thyUniqueCheck = input<(value: any) => Observable<boolean>>(undefined);
×
21

×
22
    validate(ctrl: AbstractControl): Promise<ValidationErrors | null> | Observable<ValidationErrors | null> {
×
23
        return this.thyUniqueCheck()(ctrl.value).pipe(
×
24
            map((failed: boolean) => {
25
                setTimeout(() => {
26
                    if (failed && this.thyForm && this.elementRef.nativeElement.name) {
×
27
                        this.thyForm.validator.validateControl(this.elementRef.nativeElement.name);
×
28
                    }
29
                });
1✔
30
                return failed ? { thyUniqueCheck: failed } : null;
31
            }),
32
            catchError(() => of(null))
33
        );
1✔
34
    }
35
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc