Skip to content

custom input validator function example contains syntax error and is unclear #6585

@michahell

Description

@michahell

the following example, here:
https://material.angular.io/components/input/overview
located under Custom Error Matcher contains one too many right brackets
and on top of that, is unclear:

function myErrorStateMatcher(control: FormControl, form: FormGroupDirective | NgForm): boolean {
  // Error when invalid control is dirty, touched, or submitted
  const isSubmitted = form && form.submitted;
  return !!(control.invalid && (control.dirty || control.touched || isSubmitted)));
}

why not just use:

return control.invalid && (control.dirty || control.touched || isSubmitted);

?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions