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

Document ngRequired change in changelog. #9141

Closed
leefernandes opened this issue Sep 18, 2014 · 11 comments
Closed

Document ngRequired change in changelog. #9141

leefernandes opened this issue Sep 18, 2014 · 11 comments

Comments

@leefernandes
Copy link
Contributor

Since rc.1 when a number input is undefined, ngRequired expressions are now ignored by validation. For example ng-required="1==2" has always passed validation, but now it does not.

1.3.0-beta.19: http://codepen.io/ItsLeeOwen/pen/Fjxnh

same code in 1.3.0-rc.2: http://codepen.io/ItsLeeOwen/pen/aAzrL

@leefernandes
Copy link
Contributor Author

duplicate of #9106

@caitp
Copy link
Contributor

caitp commented Sep 18, 2014

the weird thing in your demo is that the model controller gets a "number" error but not a "required" error, but in debugging, number parsing succeeds but required validation fails. I must be missing something.

I think this would be the correct behaviour if the correct error were reported, however

@leefernandes
Copy link
Contributor Author

@caitp Why should 1.3.0-rc.2 have a required error when ng-required="1==2" evaluates to false. If ng-required=false, I would expect that the number input should pass validation when undefined as it does in 1.3.0-beta.19 and below.

@caitp
Copy link
Contributor

caitp commented Sep 18, 2014

because ng-required doesn't evaluate an expression or worry about the result of the expression

@leefernandes
Copy link
Contributor Author

@caitp since when? Am I misusing the term "expression" in this context?

ngRequired evaluating an expression successfully in beta.19: http://codepen.io/ItsLeeOwen/pen/EslLp

#9106 suggests that the behavior since rc.1 is a regression bug.

@caitp
Copy link
Contributor

caitp commented Sep 18, 2014

I'm pretty sure the only difference is that ngRequired now validates the model value rather than the view value (which is probably not the right behaviour).

It didn't evaluate an expression before, as far as I can tell (or if it did, it wasn't doing it in the requiredDirective)

@gkalpak
Copy link
Member

gkalpak commented Sep 18, 2014

@caitp:
Quoting the docs:

@param {string=} ngRequired Adds `required` attribute and `required` validation constraint to
                 the element when the ngRequired expression evaluates to true. **Use `ngRequired`
                 instead of `required` when you want to data-bind to the `required` attribute.**

LOL - I was always under the assumption that it worked that way (I am not sure I ever tested it though).

This is strange...

@caitp
Copy link
Contributor

caitp commented Sep 18, 2014

I dunno, it probably did, but we broke it somehow and it's not listed as a breaking change. However looking at the blame for that directive, I don't see an obvious culprit

@gkalpak
Copy link
Member

gkalpak commented Sep 18, 2014

That's the funny thing. Looking at the code from 1.0.5 until 1.3.0-beta.x there doesn't seem to be anything about that directive that should make it work the way it is described. And yet it does !!!

Spooky...

@gkalpak
Copy link
Member

gkalpak commented Sep 18, 2014

First mystery solved: It's one of the BOOLEAN_ATTR attributes.
Now let's find out why it isn't working...

@leefernandes
Copy link
Contributor Author

We should probably move over to the #9106 issue, I closed this one because it appears to be a dupe.

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

No branches or pull requests

3 participants