Current behavior
When using the reactive forms/model-driven approach, the validation rules for HTML input elements are defined in the component class, not the HTML as attributes. This is great in that the validation can be tailored to different user types or application state. For example, a field is required for normal users but not required for admin users.
However, we lose some built-in browser functionality when these attributes are not defined in the HTML, such as limiting character entry (maxlength) and supporting accessibility (required or aria-required)
Expected/desired behavior
For built-in validation types, provide the option to add/remove attributes automatically. For example, adding the Validator.required to a control in the class should automatically add the required attribute to the DOM.
For custom validation, provide a way for the validation author to specify the attributes to add/remove from the DOM.
- Please tell us about your environment:
- Angular version: 2.0.0-RC
- Browser: all
- Language: all
Current behavior
When using the reactive forms/model-driven approach, the validation rules for HTML input elements are defined in the component class, not the HTML as attributes. This is great in that the validation can be tailored to different user types or application state. For example, a field is required for normal users but not required for admin users.
However, we lose some built-in browser functionality when these attributes are not defined in the HTML, such as limiting character entry (maxlength) and supporting accessibility (required or aria-required)
Expected/desired behavior
For built-in validation types, provide the option to add/remove attributes automatically. For example, adding the Validator.required to a control in the class should automatically add the required attribute to the DOM.
For custom validation, provide a way for the validation author to specify the attributes to add/remove from the DOM.