RequiredValidator

directive

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>

Methods

validate(control: AbstractControl): ValidationErrors | null

Parameters

control

Type: AbstractControl.

Returns

ValidationErrors | null

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

Parameters

fn

Type: () => void.

Returns

void

© 2010–2019 Google, Inc.
Licensed under the Creative Commons Attribution License 4.0.
https://v6.angular.io/api/forms/RequiredValidator