ViewModel validation seems to be usable only from the template by using VM bindings, like so:
Template.comp.viewmodel({
field: ViewModel.property.string.notBlank
});
<span {{b "if: field.invalid"}}>your field has errors</span>
But this doesn't work:
Template.comp.viewmodel({
field: ViewModel.property.string.notBlank
hasErrors() {
return this.field.invalid();
}
});
{{#if hasErrors}}<span>your field has errors</span>
This makes it really hard to use ViewModel validation in components, for example, if I have a TextBox component that accepts hasErrors as a prop.
Reproduction: https://github.com/arggh/viewmodel-validation-issue
ViewModel validation seems to be usable only from the template by using VM bindings, like so:
But this doesn't work:
This makes it really hard to use ViewModel validation in components, for example, if I have a
TextBoxcomponent that acceptshasErrorsas a prop.Reproduction: https://github.com/arggh/viewmodel-validation-issue