| 181 | const legacyErrors = signal<ValidationErrors | null>(null); |
| 182 | |
| 183 | @Component({ |
| 184 | selector: 'legacy-control-with-validators', |
| 185 | template: `<input [value]="value" (input)="onInput($event.target.value)" />`, |
| 186 | providers: [ |
| 187 | {provide: NG_VALUE_ACCESSOR, useExisting: LegacyControlWithValidators, multi: true}, |
| 188 | {provide: NG_VALIDATORS, useExisting: LegacyControlWithValidators, multi: true}, |
| 189 | ], |
| 190 | }) |
| 191 | class LegacyControlWithValidators implements ControlValueAccessor, Validator { |
| 192 | value = ''; |
| 193 | |
| 194 | private onChangeFn?: (value: string) => void; |
| 195 | |
| 196 | writeValue(newValue: string): void { |
| 197 | this.value = newValue; |
| 198 | } |
| 199 | |
| 200 | registerOnChange(fn: (value: string) => void): void { |
| 201 | this.onChangeFn = fn; |
| 202 | } |
| 203 | |
| 204 | registerOnTouched(fn: () => void): void {} |
| 205 | |
| 206 | validate(control: AbstractControl): ValidationErrors | null { |
| 207 | return legacyErrors(); |
| 208 | } |
| 209 | |
| 210 | onInput(newValue: string) { |
| 211 | this.value = newValue; |
| 212 | this.onChangeFn?.(newValue); |
| 213 | } |
| 214 | } |
| 215 | |
| 216 | @Component({ |
| 217 | imports: [LegacyControlWithValidators, FormField], |
nothing calls this directly
no test coverage detected
searching dependent graphs…