Reputation: 265
I'm trying to configure Aurelia Validation (release 0.2.6) to get all of the validation messages appended to <input>
element instead of label.
My main.js looks like this:
export function configure(aurelia) {
aurelia.use
.standardConfiguration()
.developmentLogging()
.plugin('aurelia-validation', (config) => { config.useLocale('de-DE').useViewStrategy(ValidateCustomAttributeViewStrategy.TWBootstrapAppendToInput); });
aurelia.start().then(a => a.setRoot('app', document.body));
}
I alway get the following error message:
Unhandled promise rejection ReferenceError: ValidateCustomAttributeViewStrategy is not defined
What am I doing wrong?
Upvotes: 6
Views: 951
Reputation: 3658
For aurelia validation version 1.0. It works with creating a custom renderer. See it here on section custom renderers.
Upvotes: 0
Reputation: 1340
Looks like this just recently changed. So as of 10/12/2015 this works:
import { TWBootstrapViewStrategy } from 'aurelia-validation';
...
export function configure(aurelia) {
aurelia.use
.plugin('aurelia-validation', (config) => config
.useViewStrategy(TWBootstrapViewStrategy.AppendToInput))
...
}
As an aside, the d.ts
is currently missing the definitions for the strategies so if you're using TypeScript you'll have to cast the strategy to any
:
import { ValidationConfig, TWBootstrapViewStrategy } from 'aurelia-validation';
...
export function configure(aurelia: Aurelia) {
aurelia.use
.plugin('aurelia-validation', (config: ValidationConfig) => config
.useViewStrategy((<any>TWBootstrapViewStrategy).AppendToInput))
...
}
Upvotes: 8
Reputation: 771
Add
import {ValidateCustomAttributeViewStrategy} from 'aurelia-validation';
to the top of your file
Upvotes: 3