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

atinc / ngx-tethys / d9ae709b-3c27-4b69-b125-b8b80b54f90b

pending completion
d9ae709b-3c27-4b69-b125-b8b80b54f90b

Pull #2757

circleci

mengshuicmq
fix: fix code review
Pull Request #2757: feat(color-picker): color-picker support disabled (#INFR-8645)

98 of 6315 branches covered (1.55%)

Branch coverage included in aggregate %.

1 of 1 new or added line in 1 file covered. (100.0%)

2392 of 13661 relevant lines covered (17.51%)

83.12 hits per line

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

21.05
/src/form/validator/unique-validator.directive.ts
1
import { AsyncValidator, AbstractControl, ValidationErrors, NG_ASYNC_VALIDATORS } from '@angular/forms';
2
import { Directive, Input, Optional, ElementRef } 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: [
15
        {
×
16
            provide: NG_ASYNC_VALIDATORS,
×
17
            useExisting: ThyUniqueCheckValidator,
18
            multi: true
19
        }
×
20
    ],
×
21
    standalone: true
×
22
})
×
23
export class ThyUniqueCheckValidator implements AsyncValidator {
24
    @Input() thyUniqueCheck: (value: any) => Observable<boolean>;
25

×
26
    constructor(private elementRef: ElementRef, @Optional() private thyForm: ThyFormDirective) {}
×
27

28
    validate(ctrl: AbstractControl): Promise<ValidationErrors | null> | Observable<ValidationErrors | null> {
1✔
29
        return this.thyUniqueCheck(ctrl.value).pipe(
30
            map((failed: boolean) => {
31
                setTimeout(() => {
32
                    if (failed && this.thyForm && this.elementRef.nativeElement.name) {
1✔
33
                        this.thyForm.validator.validateControl(this.elementRef.nativeElement.name);
34
                    }
35
                });
36
                return failed ? { thyUniqueCheck: failed } : null;
1✔
37
            }),
38
            catchError(() => of(null))
39
        );
40
    }
41
}
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

© 2025 Coveralls, Inc