-
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
ko.validation.group unexpected null entry #99
Comments
Same problem appears even in sipler case with When I have two fileds, empty by default, that requires value, errors count is equal to 2 (as desired), |
I don't know if this behavior is desired, but I found a solution. To force Using previous example: ko.validation.group(self.rows()); // add parentheses |
I figured this out for anyone that comes across this. if your group is an observableArray, you need to just pass the unwrapped array as the group. My app uses a validation function because I have groups attached to Tab objects, so I just check if the group coming in is an observable array and then call the observable in that scenario. var TabValidation = function (tab) {
|
The real problem is in function collectErrors(array) {
var errors = [];
ko.utils.arrayForEach(array, function (observable) {
if (!observable.isValid()) {
// Use peek to prevent a dependency to 'error' property because it
// changes before 'isValid' does. (Issue #99)
errors.push(observable.error.peek());
}
});
return errors;
} |
Working example http://jsfiddle.net/tnj6u5fs/ |
I'm not sure if I'm using group correctly, but
I try to get array of errors from my observableArray elements
http://jsfiddle.net/tomalec/DWACW/
The problem is that if you enter both invalid values,
null
appears inko.validation.group(self.rows, { deep: true, observable: true });
I found that
null
comes fromself.rows.isValid()
, but I didn't set any validator on observableArray itself.If it is cascading effect, then why it doesn't appear in case on one invalid field?
Is there a way to get array without that effect? As I would say that array itself is fine for me, as it have proper length, etc.
The text was updated successfully, but these errors were encountered: