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

atinc / ngx-tethys / a471af92-5b42-4cf9-bc34-baa8632b60c1

05 Aug 2024 08:33AM UTC coverage: 90.468%. Remained the same
a471af92-5b42-4cf9-bc34-baa8632b60c1

push

circleci

minlovehua
fix: fix review

5498 of 6722 branches covered (81.79%)

Branch coverage included in aggregate %.

13246 of 13997 relevant lines covered (94.63%)

997.56 hits per line

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

19.51
/src/date-picker/picker.validators.ts
1
import { Directive, Input, StaticProvider, forwardRef } from '@angular/core';
2
import { AbstractControl, NG_VALIDATORS, ValidationErrors, Validator } from '@angular/forms';
3
import { instanceOfDateEntry, instanceOfRangeEntry } from './picker.util';
4
import { DateEntry, ThyDateRangeEntry } from './standard-types';
5

1✔
6
const DATE_PICKER_REQUIRED_VALIDATOR: StaticProvider = {
7
    provide: NG_VALIDATORS,
×
8
    useExisting: forwardRef(() => DatePickerRequiredValidator),
9
    multi: true
10
};
11

12
/**
13
 * @private
1✔
14
 */
15
@Directive({
×
16
    selector:
17
        '[thyDatePicker][required][formControlName],[thyDatePicker][required][formControl],[thyDatePicker][required][ngModel],thy-date-picker[required][formControlName],thy-date-picker[required][formControl],thy-date-picker[required][ngModel]',
18
    providers: [DATE_PICKER_REQUIRED_VALIDATOR],
×
19
    standalone: true
20
})
21
export class DatePickerRequiredValidator implements Validator {
×
22
    private _required!: boolean;
23

24
    @Input()
×
25
    get required(): boolean | string {
26
        return this._required;
1✔
27
    }
28

29
    set required(value: boolean | string) {
30
        this._required = value != null && value !== false && `${value}` !== 'false';
1✔
31
    }
32

33
    validate(control: AbstractControl): ValidationErrors | null {
34
        return this.required ? this.validateRequired(control) : null;
35
    }
36

37
    private validateRequired(control: AbstractControl): ValidationErrors | null {
38
        return isEmptyInputDateValue(control.value) ? { required: true } : null;
1✔
39
    }
40
}
×
41

42
const RANGE_PICKER_REQUIRED_VALIDATOR: StaticProvider = {
43
    provide: NG_VALIDATORS,
44
    useExisting: forwardRef(() => RangePickerRequiredValidator),
45
    multi: true
46
};
1✔
47

48
/**
×
49
 * @private
50
 */
51
@Directive({
×
52
    selector:
53
        '[thyRangePicker][required][formControlName],[thyRangePicker][required][formControl],[thyRangePicker][required][ngModel],thy-range-picker[required][formControlName],thy-range-picker[required][formControl],thy-range-picker[required][ngModel]',
54
    providers: [RANGE_PICKER_REQUIRED_VALIDATOR],
×
55
    standalone: true
56
})
57
export class RangePickerRequiredValidator implements Validator {
×
58
    private _required!: boolean;
59

1✔
60
    @Input()
61
    get required(): boolean | string {
62
        return this._required;
63
    }
1✔
64

65
    set required(value: boolean | string) {
66
        this._required = value != null && value !== false && `${value}` !== 'false';
67
    }
68

69
    validate(control: AbstractControl): ValidationErrors | null {
70
        return this.required ? this.validateRequired(control) : null;
71
    }
72

×
73
    private validateRequired(control: AbstractControl): ValidationErrors | null {
74
        return isEmptyInputRangeValue(control.value) ? { required: true } : null;
75
    }
×
76
}
77

78
function isEmptyInputRangeValue(value: ThyDateRangeEntry): boolean {
79
    return value == null || (instanceOfRangeEntry(value) && (value.begin == null || value.end == null));
80
}
81

82
function isEmptyInputDateValue(value: DateEntry): boolean {
83
    return value == null || (instanceOfDateEntry(value) && value.date == null);
84
}
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