Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Configuration of aurelia-validation

Tags:

aurelia

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?

like image 550
doeck Avatar asked Jul 02 '15 14:07

doeck


2 Answers

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))
        ...
}
like image 136
hcoverlambda Avatar answered Nov 14 '22 19:11

hcoverlambda


Add import {ValidateCustomAttributeViewStrategy} from 'aurelia-validation'; to the top of your file

like image 3
JamesCarters Avatar answered Nov 14 '22 19:11

JamesCarters