-
Notifications
You must be signed in to change notification settings - Fork 369
Open
Labels
Milestone
Description
When setting up validation, you can assign an value for comparison directly:
var myVal = ko.observable().extend({
minLength: 3,
});Or you can assign an object if you want to customize the error message:
var myVal = ko.observable().extend({
minLength: {
params: 3,
message: "That is too short!"
},
});I like to be consistent in how I set up my validation, regardless of whether I need to customize the message or not. So sometimes I'd like to do this (keeping the default error message):
var myVal = ko.observable().extend({
minLength: {
params: 3
},
});But this doesn't work. ko validation compares the length of the value in my observable with { params: 3 } rather than comparing it with 3.
I suggest changing KO validation so that you can assign an object, such as my last example, even when there is no message property on that object.
If you like the idea I can work on a pull request.