Having issues with running simple validation rule examples on a component in au2.
A very basic component form page below that is routed from a router.
import { bindable, Params, IRouter, IRouteViewModel } from 'aurelia';
import { IValidationRules } from '@aurelia/validation';
import { IValidationController } from '@aurelia/validation-html';
import { newInstanceForScope } from '@aurelia/kernel';
import template from './contact-form.html';
class Contact {
public constructor(
public name: string,
public email: string,
public message: string
){}
}
export class ContactForm implements IRouteViewModel {
private contact: Contact;
public constructor (
@newInstanceForScope(IValidationController) private controller: IValidationController,
@IValidationRules private validationRules: IValidationRules
)
{
this.contact = new Contact(undefined, undefined, undefined);
validationRules
.on(this.contact)
.ensure('name')
.required();
}
public async submit(){
//const result = await this.validationController.validate();
//console.log(result);
}
}
When you flip to the page you get the error:
Uncaught (in promise) Error: AUR0012:IPlatform
at Container.R (index.js?8966:1047:1)
at Container.get (index.js?8966:929:1)
at Container.at (index.js?8966:759:1)
at Array.map (<anonymous>)
at Container.invoke (index.js?8966:961:1)
at ValidationControllerFactory.construct (index.mjs?c5e3:276:1)
at ct (index.js?8966:682:1)
at eval (index.js?8966:673:1)
at n.resolve (index.js?8966:613:1)
at Container.get (index.js?8966:921:1)
Any ideas? I tried various constructor arguments. I followed the au2 docs to install and register “ValidationHtmlConfiguration” with defaults. Maybe I’m misunderstanding something because I’m much more used to ES/js.