This is the archived documentation for Angular v6. Please visit angular.io to see documentation for the current version of Angular.

RequiredValidator

A Directive that adds the required validator to any controls marked with the required attribute, via the NG_VALIDATORS binding.

NgModules

Selectors

  • :not([type=checkbox])[required][formControlName]
  • :not([type=checkbox])[required][formControl]
  • :not([type=checkbox])[required][ngModel]

Properties

Property Description
@Input()
required: boolean | string

Description

Example

<input name="fullName" ngModel required>
      
      <input name="fullName" ngModel required>
    

Methods

validate(control: AbstractControl): ValidationErrors | null
      
      validate(control: AbstractControl): ValidationErrors | null
    

Parameters

control

Type: AbstractControl.

Returns

ValidationErrors | null

registerOnValidatorChange(fn: () => void): void
      
      registerOnValidatorChange(fn: () => void): void
    

Parameters

fn

Type: () => void.

Returns

void