Skip to content
This repository was archived by the owner on Apr 12, 2024. It is now read-only.

feat(ngModelController): add $warning #13465

Open
0x-r4bbit opened this issue Dec 8, 2015 · 4 comments
Open

feat(ngModelController): add $warning #13465

0x-r4bbit opened this issue Dec 8, 2015 · 4 comments

Comments

@0x-r4bbit
Copy link
Contributor

We currently have $error as part of ngModelController and formController to represent errors when validations have failed on certain form inputs.

This is already super powerful and covers almost all use cases, however, recently when I was reviewing an application a new use case occurred.

Motivation

Some inputs of a form of the application allow any value but should display a warning if the value is a different type of what it is supposed to be.

Example:

A text input for phone number. The user is allowed to type in numbers and letters and the model gets updated, but should get a warning that displays information that it might be a wrong value.

Proposal

Introduce $warning next to $error on ngModelController/FormController to take advantage of the same mechanisms we use to display errors (ngMessages, etc.) except that the model gets updated regardless of if warning occurs or not.

/cc @cburgdorf

@Narretz
Copy link
Contributor

Narretz commented Dec 10, 2015

Definitely a use case.
I wonder if we can make this more generic, though. Add warning and next thing you know people want hint, info etc. ;)
A generic "info" property or similar on the model could help. Validators would still work like before, but if they pass, they would be added to the info array and be accessible there. Validators should also be able to return metadata information (hint texts, type) etc., that can be accessed by the template. The model would still be blocked from update if there's an error.

@0x-r4bbit
Copy link
Contributor Author

I like the sound of that.

@thorgilsv
Copy link

You seem to me to be addressing my problem. Hope this gets picked up soon.
In javascript there are three ways of notifying the user: alarm, confirm and prompt. If $error matches alarm then $warning or $info would match confirm and prompt right?

@rburnham52
Copy link

I just had a scenario where this would be very handy. Basically we have the option to select an address via predictive address lookup. This gives us a unique ID matching the address, but just in case we allow the user to manually edit the fields. Now technically this does not make it invalid, but it would be nice to detect when they manually edit a field and display a warning to double check their address is correct or we might not be able to contact them by post.

It would have been nice to utilize the existing ng-messages to show this.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

4 participants