-
Notifications
You must be signed in to change notification settings - Fork 379
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Getting observables associated with errors? #449
Comments
Bump. We have a more limited case for this need, wanting only a collection of validation errors which have been evaluated/ shown. It can be accomplished by adding a new method, like:
However, the comment above (plus previous discussions) would handle this case and more. |
Thanks @askheaves There are more use cases which require access to |
If I wrote this up, would you accept it as a pull request? It should be something pretty simple, like this:
If you worry about the raw observables getting mucked with, an alternative would be to project the validatables into their own collection, something like:
|
Looking at the second example it makes me think the first option is much better. I would be fine with adding this method but I would also like to have the |
I'm ok with doing a find and filter and submitting that. The main advantage to option 2 (return a projected array) is that all array functions are immediately available, and you don't expose any underlying structure. The downside is a new object schema which I've put very little thought into so far. With option 1 we may be playing catch up on needed collection functions, but we can get a lot of mileage out of find, filter and map (and maybe forEach). I'll rough up these functions and tests today and get a pull request in your direction. |
To be honest I wish it could be a better way to do all this. One of the problems of option 2 is that the computed will be eagerly evaluated and if |
I'm good with all that, and the eager evaluation is a good point. I have the 4 methods coded up now (find, filter, map, forEach), and am currently writing up the unit tests. I should have something for you today. |
👍 |
Awesome. Thanks! |
I have noticed a few other issues related to this such as:
#298
However I cannot find any documentation around if this sort of thing made it into the main branch and if so how to best use it.
My scenario is in nodejs on a webservice I get sent json which I convert into a model with validation rules applied then via the
group
method I get all the errors, then throw them back as errors if something failed validation. However all I get is the errors, and I can manually go change the code, however every time a release happens and it pulls the latest version of knockout.validation from npm I will lose it :(So is there any way to get the errors and the observable name or property it is linked to?
(If this functionality is already existing it could just be that the npm package for knockout validation just needs updating)
The text was updated successfully, but these errors were encountered: