似乎在aurelia-validation模块方面存在各种问题,但我没有看到任何解决我遇到的具体问题的问题。
我有一个模型类,其定义和验证规则如下:
我-model.js
my-model = { "name": { "full": "", "short": "", } }; ... ValidationRules .ensure(model => model.name.full).required().minLength(5).maxLength(50) .on(this.my-model);但是,当我在浏览器中尝试它时,我收到错误:
... Inner Error: Message: Unable to parse accessor function: function (model) { return model.name.full; } ...这个问题是我能够看到最接近我的问题的问题,而另一个问题似乎也有同样的问题。
我正在运行aurelia-framework@^1.0.2和aurelia-validation@^1.0.0-beta.1.0.1 ,我认为这只是定期更新的默认值(但也是它突然无法工作的原因)。 是否有可能我仍在运行某些模块的不兼容版本? 或者我的代码中的其他地方是否需要修复?
It seems there have been various problems elsewhere in regards to the aurelia-validation module, but I haven't seen anything that has addressed the specific problem I've been running into.
I have a model class with the definition and validation rules as below:
my-model.js
my-model = { "name": { "full": "", "short": "", } }; ... ValidationRules .ensure(model => model.name.full).required().minLength(5).maxLength(50) .on(this.my-model);When I try it in the browser, however, I get the error:
... Inner Error: Message: Unable to parse accessor function: function (model) { return model.name.full; } ...This question was the closest I was able to see to my problem, and another here seems to be having the same issue.
I am running aurelia-framework@^1.0.2 and aurelia-validation@^1.0.0-beta.1.0.1 which I believe are just the defaults from regular updates (but also the reason for it suddenly not working). Is it possible I'm still running incompatible versions of some modules? Or is there somewhere elsewhere in my code that I need to fix?
最满意答案
如果您定位属性而不是对象怎么办? 那样有用吗?
myModel = { "name": { "full": "", "short": "", } }; ValidationRules .ensure(model => model.full) .required() .minLength(5) .maxLength(50) .on(this.myModel.name); //<--- seeWhat if you target the property instead of the object? Does that work?
myModel = { "name": { "full": "", "short": "", } }; ValidationRules .ensure(model => model.full) .required() .minLength(5) .maxLength(50) .on(this.myModel.name); //<--- see更多推荐
发布评论