asp.net MVC 验证框架的选项

发布于 2024-07-15 11:16:11 字数 453 浏览 4 评论 0原文

我现在正在考虑两个选项,用于对我正在启动的 ASP.net 项目进行基于模型的验证:

xVal< /a> (Steve Sanderson 的项目)和 Stephen Walther 在 此页面

我真的不太了解如何谈论首选项,因为我还没有使用过其中任何一个。 有任何想法吗?

更新 现在使用 LinqToSql 进行 ORM,但我愿意接受更改。

I'm thinking of two options right now for model-base validation for an ASP.net project I'm starting:

xVal (Steve Sanderson's project) and the Enterprise module that Stephen Walther uses on this page

I don't really know enough to talk about the preferences as I haven't used either of them yet. Any ideas?

Update Using LinqToSql for ORM right now, but am open to changes.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(7

驱逐舰岛风号 2024-07-22 11:16:12

无耻地宣传我的验证库。 专为 jQuery 验证而构建 企业库和开箱即用的功能就是为了这一点。 也就是说,功能和代码足够简单,可以根据需要进行修改/扩展。

Shamelessly promote my validation library. Built for jQuery validate & Enterprise Library and work out of the box for just that. That said, functionality and code are simple enough to modify/extend if you want.

泅人 2024-07-22 11:16:12

您还可以在 LosTechies http://www.lostechies.com/blogs/hex/archive/2009/06/10/opinionated-input-builders-for- asp-net-mvc-part-5-the-required-input.aspx 我喜欢这样一个事实,即您的输入是全局设置的,这确实很干燥。 此外,您还可以跳过客户端验证,并执行 jquery ajax 提交表单到服务器,该服务器在一个地方执行验证模型和业务逻辑,这也是 DRY :) 这也意味着您将更快地推出产品您可以稍后添加客户端验证作为奖励或逐步增强表单。

You could also check out this new technique on LosTechies http://www.lostechies.com/blogs/hex/archive/2009/06/10/opinionated-input-builders-for-asp-net-mvc-part-5-the-required-input.aspx I like the fact that you inputs are setup globaly which is really DRY. Also you could just skip the client side validation and do an jquery ajax submit form to the server, which performs validation model and business logic all in one place, which is also DRY :) Also it means you will get the product out the door quicker and you can add client side validation later as a bonus or to progressively enhance the forms.

动听の歌 2024-07-22 11:16:12

再次投票给 xVal。 真的很甜。 我喜欢使用 好友类DataAnnotations 来进行验证提升。 除了使用 Linq2Sql 进行工作之外(因为您无法向字段添加属性),伙伴类还提供了一点灵活性,可以让多个模型共享相同的验证信息。 对于那些似乎总是必需的 ModelEditData 类来说非常方便。

Another vote for xVal. It's real sweet. I like using Buddy Classes and DataAnnotations to do the validation lifting. Outside of making things work with Linq2Sql as you cannot add attributes to your fields, buddy classes give one a bit of flexibility to have multiple models share the same validation info. Comes in real handy for those ModelEditData classes that seem to always become neccessary.

迟到的我 2024-07-22 11:16:12

你使用 ORM 吗? 如果是,您使用的是哪一款? 在使用 Castle ActiveRecord 时,我很幸运,只需坚持使用默认的模型级验证即可。 但是,如果您不使用它,这可能没有太大帮助。 :-)

Are you using an ORM? If so, which one are you using? I've had a lot of luck, when using Castle ActiveRecord, simply sticking with their default model-level validation. If you're not using that, though, this is probably not too helpful. :-)

黯然#的苍凉 2024-07-22 11:16:11

我在回顾两者时发现的一个区别是 Stephen Walther 的博客文章描述了一个仅在 Web 服务器中进行验证的库,而 xVal 与 jQuery 验证器一起工作也可以在浏览器中进行验证。 顺便说一下,这个功能几乎是完全自动的。

One difference I see in reviewing the two is that Stephen Walther's blog post describes a library which does only validation in the Web server, where as xVal works with jQuery validators to do in-browser validation, as well. This feature, incidentally, is almost completely automatic.

溇涏 2024-07-22 11:16:11

FluentValidation 很好。 NHibernate 还内置了模型验证。 然后你需要类似 Scott Guthrie 的将错误绑定到 UI 的技术

FluentValidation is nice. NHibernate also has built in model validation. Then you need something like Scott Guthrie's technique for binding errors to the UI.

陌伤ぢ 2024-07-22 11:16:11

我一直在使用 xVal,并将其集成到 MVC RC1 中引入的 IDataErrorInfo 接口中。 我喜欢。

这是我写的一篇文章,解释了一些事情。

http://schotime .net/blog/index.php/2009/03/05/validation-with-aspnet-mvc-xval-idataerrorinfo/

希望这有帮助。

I've been using xVal to and i have integrated it into the IDataErrorInfo interface introduced into MVC RC1. I like it.

Here is a post I wrote which explains a few things.

http://schotime.net/blog/index.php/2009/03/05/validation-with-aspnet-mvc-xval-idataerrorinfo/

Hope this helps.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文