我试图在课堂上添加以下验证
ValidationRules
.ensure("disputeAmount").required({ fullMessages: true, message: 'Required' })
.when(a => a.canBeDisputed)
.on(BillItem);
必需的验证工作正常。但是当我添加 when 子句时,我收到了这个错误:
[app-router] Error: (SystemJS) TypeError:
aurelia_validatejs_1.ValidationRules.ensure(...).required(...).when is not a function
以下是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"
},
这与aurelia-validation的版本有关吗?如果是这样,我如何更新它? (该项目不是由我设立的)
答案 0 :(得分:0)
最新版本的aurelia-validation是1.1.1,但您使用的是0.10.0
package.json文件定义运行npm install
如果您在那里更改版本并删除node_modules文件夹,然后运行npm install
,您将获得最新版本。然后更新config.js以使用1.1.1