Aurelia验证规则:无法解析访问者功能(Aurelia Validation Rules: Unable to parse accessor function)

编程入门 行业动态 更新时间:2024-10-28 04:29:14
Aurelia验证规则:无法解析访问者功能(Aurelia Validation Rules: Unable to parse accessor function)

似乎在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); //<--- see

What 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

更多推荐

本文发布于:2023-08-01 15:47:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1362811.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:访问者   规则   功能   Validation   Aurelia

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!