基于PHP的表单验证助手?

基于PHP的表单验证助手?

问题描述:

From my time working with Ruby On rails, there is a couple different packaged/projects out there to manage both validation and error reporting in an extensible way.

Self-studying Python Pylons I just got introduced to HTMLFill which so far seems like an elegant solution to a common task of form validation.

I know both examples are features of Frameworks, or in the case of HTMLFill, intended to be part of a framework... still I don't remember seeing anything remotely as well polished in cakephp, code igniter, or even Zend framework. Am I missing something out there, or would it be worth while to attempt to imitate Python's HTMLFill in PHP5?

disclaimers: I've written Ajax based form validation systems that rely on embedding metadata like class="data-required data-email" and like but they've always seemed clunky to me.

I believe in the fat model philosophy of data validation, with the HTMLFill example above, I plan on packing my models with common HTMLFill schemes to each model, as is possible.

Links: HTMLFill - http://www.formencode.org/htmlfill.html#introduction

从我使用Ruby On rails开始,有几个不同的打包/项目来管理验证和 以可扩展的方式报告错误。 p>

自学Python Pylons我刚刚介绍了HTMLFill,到目前为止,这似乎是表单验证常见任务的优雅解决方案。 p> \ n

我知道两个例子都是Frameworks的功能,或者在HTMLFill的情况下,打算成为框架的一部分......我仍然不记得在cakephp,代码点火器, 甚至是Zend框架。 我是否遗漏了某些内容,或者尝试在PHP5中模仿Python的HTMLFill是否值得? p>

免责声明: 我编写了依赖于嵌入的基于Ajax的表单验证系统 像class =“data-required data-email”之类的元数据,但它们对我来说似乎总是很笨拙。 p>

我相信数据验证的胖模型哲学,HTMLFill示例 在上面,我计划尽可能将模型与常见的HTMLFill方案打包到每个模型。 p>

链接: HTMLFill - http://www.formencode.org/htmlfill.html#introduction p> div>

The Zend Framework has the Zend_Validate class, it provides you a basic set of validators, you have also the Zend_Filter_Input class for data filtering, validation and escaping.

I've also used Propel ORM Validation Framework to do validation at the model level.

You can also enforce validation at the client side level, I recommend you the jQuery Validation plugin, it works really good...

The Zebra Form library is pretty nice and automatically generates javascript to do client-side validation as well.

http://stefangabos.ro/php-libraries/zebra-form/