Skip to content

create directive to handle display of form validity #1

Open
@samrichardsontylertech

Description

@samrichardsontylertech

Describe the feature:
Currently showing the required and invalid status of a form field requires developers to set the required attribute of the element and bind to the invalid property, checking both the invalid and touched properties of the form control. For required, this involves setting the attribute separately from the form validators and increasing the risk of bugs. It also forces developers to remember the difference between touched and dirty and consistently implement the validity check correctly, increasing code repetition, the risk for bugs, and the cognitive burden of developing a front end.

These properties can instead be abstracted into an Angular directive that takes in a form control and listens for status updates, setting the properties based on the state of the control itself. This approach is already taken by a few teams and should be made available more widely. The directive could also be expanded on in the future to handle other form related features.

Describe any alternatives you've considered:
The alternative is to continue setting required and invalid manually, but as noted above this can be tedious and prone to bugs.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions