Created
February 7, 2016 18:00
-
-
Save imbalind/f92f12477b0839e6e712 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Live validation thread |
Thanks @imbalind. Here are my 2 cents:
- I agree with most of your points. It was never meant to replace your validator - only enhance it. What I've sent is a POC. It works along with your great validator, and adds the live edit to it as well as the integration with ngForm (in my app the grid (or several of them) are a part of a bigger form).
- I'm working with enterprise apps only, and they expect this behavior (I've created something somewhat similar in my own app, but really liked your validator so decided to go along :)).
- Enable/disable is definitely a must with every feature, and I think for every column as well. Not every column needs live validation.
- I've used the $parser because it handles live edit of the input the "angular" way, without adding a new
$watch
. - Regarding how to know which validations failed - I think you could return the promises from the
runValidators
method, so anyone using it could tell what has failed "live" (I'm using atimeout
there, but it's bad practice - promises are much more reliable). - the
addValidator
assumes you are using an input to edit. Is there another scenario in which you would like live editing? - I also don't like the
while
there. Any good ideas on how to get the cell element without it? I think that jQuery's solution (parentsUntil
) works roughly the same...
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Some thoughts about @yccteam's live validation gitter:
I'd rather move to directive style because it looks more "angular" and I think it should give better performance but I don't know if we could provide a behaviour like ng-class to add the $invalid class when validation fails after the user stops editing.
To answer the question in your code: actually the only way to know which validations failed, would be to scan the row entity for any field starting with
'$$errors'+colDef.name
, we could think about adding something to the row too, like an array or a property.addValidator
will need to be customized for any element (maybe a decorator to use with custom template?)$parsers
that calls a validator? I'd add a validator to$validators
liveValidator
'slink
function, but I don't actually know whether there's a better way around it or not.