aurelia / validatejs

Enables expressive validation using decorators and/or a fluent API.
MIT License
22 stars 23 forks source link

validator.ensure is not a function #105

Closed mackecar closed 8 years ago

mackecar commented 8 years ago

This is my code: `import {inject} from "aurelia-framework"; import {DataRepo} from "./dataRepo"; import {Router} from "aurelia-router"; import {Validator} from 'aurelia-validatejs';

@inject(DataRepo,Router,Validator) export class AddNew{ constructor(dataRepo,router,validator) { this.dataRepo = dataRepo; this.router = router; this.validator = validator.ensure(this.person, 'FirstName').required(); }` and this is Error:

`aurelia-logging-console.js:54 ERROR [app-router] Error: Error invoking AddNew. Check the inner error for details.

Inner Error: Message: validator.ensure is not a function Inner Error Stack: TypeError: validator.ensure is not a function at new AddNew (http://localhost:60808/Users/addNew.js!transpiled:29:48) at Object.invoke (http://localhost:60808/jspm_packages/npm/aurelia-dependency-injection@1.0.0-rc.1.0.0/aurelia-dependency-injection.js:362:14) at InvocationHandler.invoke (http://localhost:60808/jspm_packages/npm/aurelia-dependency-injection@1.0.0-rc.1.0.0/aurelia-dependency-injection.js:321:168) at Container.invoke (http://localhost:60808/jspm_packages/npm/aurelia-dependency-injection@1.0.0-rc.1.0.0/aurelia-dependency-injection.js:585:25) at StrategyResolver.get (http://localhost:60808/jspm_packages/npm/aurelia-dependency-injection@1.0.0-rc.1.0.0/aurelia-dependency-injection.js:123:37) at Container.get (http://localhost:60808/jspm_packages/npm/aurelia-dependency-injection@1.0.0-rc.1.0.0/aurelia-dependency-injection.js:522:23) at eval (http://localhost:60808/jspm_packages/npm/aurelia-templating@1.0.0-rc.1.0.0/aurelia-templating.js:4412:73) End Inner Error Stack`

What is a problem?

EisenbergEffect commented 8 years ago

@jdanyow Is this correct api usage?

jdanyow commented 8 years ago

looks like the old API- sorry @mackecar the docs haven't caught up with the validation overhaul yet. Use this instead: http://blog.durandal.io/2016/06/14/new-validation-alpha-is-here/

I'll add a note to the readme.