We are building a Single Page Application using Knockout, Durandal & Breeze.
We have a observable array, & want to validate whether it contains any value or not i.e. the text box accepting values has been provided with any value or not. I am trying to achieve this using Knockout.Validation plugin.
Code for view model is-
withs = ko.observableArray([]).extend({ required: true }),
and HTML is
<div class="col-lg-9">
<select multiple="true"
data-bind="options: entities, optionsValue: 'Id', optionsText: 'Name',
selectedOptions: withs, select2: {}"
style="width: 249px; border-radius: 4px;"></select>
</div>
Here is an alternate approach.
Thewad's solution is certainly valid, but if you don't have a call to registerExtenders() after your custom validation rule it could explain why the validation wasn't working for you.