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

atinc / ngx-tethys / #94

12 Aug 2025 05:53AM UTC coverage: 90.345% (+0.02%) from 90.324%
#94

push

web-flow
Merge 79e13dd53 into aa9fa8ee2

5531 of 6813 branches covered (81.18%)

Branch coverage included in aggregate %.

350 of 378 new or added lines in 20 files covered. (92.59%)

61 existing lines in 11 files now uncovered.

13970 of 14772 relevant lines covered (94.57%)

904.12 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, StaticProvider, forwardRef, input } 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

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

12
/**
13
 * @private
14
 */
1✔
15
@Directive({
UNCOV
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
})
20
export class DatePickerRequiredValidator implements Validator {
21
    readonly required = input(false, {
22
        transform: (value: boolean | string) => {
NEW
23
            return value != null && value !== false && `${value}` !== 'false';
×
24
        }
25
    });
UNCOV
26

×
27
    validate(control: AbstractControl): ValidationErrors | null {
28
        return this.required() ? this.validateRequired(control) : null;
1✔
29
    }
30

31
    private validateRequired(control: AbstractControl): ValidationErrors | null {
32
        return isEmptyInputDateValue(control.value) ? { required: true } : null;
1✔
33
    }
34
}
35

36
const RANGE_PICKER_REQUIRED_VALIDATOR: StaticProvider = {
37
    provide: NG_VALIDATORS,
38
    useExisting: forwardRef(() => RangePickerRequiredValidator),
39
    multi: true
1✔
40
};
UNCOV
41

×
42
/**
43
 * @private
44
 */
45
@Directive({
46
    selector:
47
        '[thyRangePicker][required][formControlName],[thyRangePicker][required][formControl],[thyRangePicker][required][ngModel],thy-range-picker[required][formControlName],thy-range-picker[required][formControl],thy-range-picker[required][ngModel]',
1✔
48
    providers: [RANGE_PICKER_REQUIRED_VALIDATOR]
UNCOV
49
})
×
50
export class RangePickerRequiredValidator implements Validator {
NEW
51
    readonly required = input(false, {
×
52
        transform: (value: boolean | string) => {
53
            return value != null && value !== false && `${value}` !== 'false';
54
        }
55
    });
UNCOV
56

×
57
    validate(control: AbstractControl): ValidationErrors | null {
58
        return this.required() ? this.validateRequired(control) : null;
UNCOV
59
    }
×
60

61
    private validateRequired(control: AbstractControl): ValidationErrors | null {
1✔
62
        return isEmptyInputRangeValue(control.value) ? { required: true } : null;
63
    }
64
}
65

1✔
66
function isEmptyInputRangeValue(value: ThyDateRangeEntry): boolean {
67
    return value == null || (instanceOfRangeEntry(value) && (value.begin == null || value.end == null));
68
}
69

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