{ "id": "api/forms/RequiredValidator", "title": "RequiredValidator", "contents": "\n\n
\n
\n
\n \n API > @angular/forms\n
\n \n
\n \n
\n

RequiredValidatorlink

\n \n \n \n \n \n
\n \n \n\n
\n \n
\n

A directive that adds the required validator to any controls marked with the\nrequired attribute. The directive is provided with the NG_VALIDATORS multi-provider list.

\n\n \n
\n \n \n \n \n
\n

See alsolink

\n \n
\n\n\n

NgModuleslink

\n\n\n\n \n
\n

Selectorslink

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

Propertieslink

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
PropertyDescription
\n \n @Input()
required: boolean | string
\n
\n \n

Tracks changes to the required attribute bound to this directive.

\n\n \n
\n
\n\n\n\n \n\n\n \n
\n

Descriptionlink

\n \n

Adding a required validator using template-driven formslink

\n\n<input name=\"fullName\" ngModel required>\n\n\n
\n \n\n \n\n \n\n \n\n \n \n \n\n
\n
\n\n\n" }