import { Pipe, type PipeTransform } from '@angular/core';
import { Validators, type AbstractControl } from '@angular/forms';

@Pipe({
  name: 'hasRequiredValidator',
  standalone: true,
})
export class ReactiveFormHasRequiredValidatorPipe implements PipeTransform {
  transform(value: AbstractControl | null, controlName?: string): boolean {
    const control = controlName ? value?.get(controlName) : value;
    return !!control?.hasValidator(Validators.required);
  }
}
