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:aurelia-validatejs@0.6.0",
"aurelia-validation": "npm:aurelia-validation@0.10.0",
"npm:aurelia-validatejs@0.6.0": {
"aurelia-metadata": "npm:aurelia-metadata@1.0.0-rc.1.0.0",
"aurelia-validation": "npm:aurelia-validation@0.10.0",
"validate.js": "npm:validate.js@0.10.0"
},
"npm:aurelia-validation@0.10.0": {
"aurelia-binding": "npm:aurelia-binding@1.0.0-rc.1.0.2",
"aurelia-dependency-injection": "npm:aurelia-dependency-injection@1.0.0-rc.1.0.0",
"aurelia-metadata": "npm:aurelia-metadata@1.0.0-rc.1.0.0",
"aurelia-task-queue": "npm:aurelia-task-queue@1.0.0-rc.1.0.0",
"aurelia-templating": "npm:aurelia-templating@1.0.0-rc.1.0.0"
},
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)
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