Knockout-Validation icon indicating copy to clipboard operation
Knockout-Validation copied to clipboard

Allow validation params in object without custom message

Open codethug opened this issue 10 years ago • 1 comments
trafficstars

Implements change discussed in #554

Before this change, you had to specify either a custom message or an onlyIf property in order to use a params object, such as this:

var testObj = ko.observable('something').extend({
  minLength: {
    params: 9,
    message: "not long enough"
  }
});

But you couldn't omit the custom message, even if you were happy with the default message. Without this pull request, this won't work:

var testObj = ko.observable('something').extend({
  minLength: {
    params: 9
    // no custom message
  }
});

You would see an error like this: Please enter at least [object Object] characters.

This pull request allows you to omit the message property and see an error message as expected. In this example, the error message would be Please enter at least 9 characters.

codethug avatar May 20 '15 19:05 codethug

Thanks @codethug

Merged into v2.1.0 branch 18a554fe2e151aad7771881401b8d14428547af9

crissdev avatar Jun 01 '15 17:06 crissdev