I have just ran into a case where I need to validate plain strings which are not a named property of an object but elements of an array.
I have tried roughly the following code, but it does not seem to work:
this._optionRules = ValidationRules .ensure((o: string) => o.length).min(1).withMessage(requiredMessage) .rules;
<li repeat.for="option of options"> <!-- options: string --> <custom-input value.bind="options[$index] & validate:_optionRules"></custom-input> <!-- wrapper for html input --> </li>
- binding the
optionobject directly does not work at all (since it is a primitive I assume it does not get propagated correctly)
- a simple
.ensure(o=>o).required()does not work either since the parser fails.