Search code examples
systemjsaurelia

Error when I try to use ".when()" in ValidationRules


I'm trying to add the following validation on a class

ValidationRules
.ensure("disputeAmount").required({ fullMessages: true, message: 'Required' })
.when(a => a.canBeDisputed)
.on(BillItem);

The required validation works fine. But when I add the when clause I get this error:

[app-router] Error: (SystemJS) TypeError:
aurelia_validatejs_1.ValidationRules.ensure(...).required(...).when is not a function


Below are the relevant items from config.js

"aurelia-validatejs": "npm:[email protected]",
"aurelia-validation": "npm:[email protected]",
"npm:[email protected]": {
  "aurelia-metadata": "npm:[email protected]",
  "aurelia-validation": "npm:[email protected]",
  "validate.js": "npm:[email protected]"
},
"npm:[email protected]": {
  "aurelia-binding": "npm:[email protected]",
  "aurelia-dependency-injection": "npm:[email protected]",
  "aurelia-metadata": "npm:[email protected]",
  "aurelia-task-queue": "npm:[email protected]",
  "aurelia-templating": "npm:[email protected]"
},

Is this something to with the Version of aurelia-validation? If so how do i update it? (The project is not set up by me)


Solution

  • The latest version of aurelia-validation is 1.1.1 but you are using 0.10.0

    The package.json file defines the version that npm will install when you run npm install

    If you change the version there and remove the node_modules folder and then run npm install you will get the latest version. Then update config.js to use 1.1.1