The above example performs a validation using the built-in validator “InclusionIn”. It checks the value of the field “type” in a domain list. If the value is not included in the method then the validator will fail and return false. The following built-in validators are available:

Name Explanation Example
PresenceOf Validates that a field’s value isn’t null or empty string. This validator is automatically added based on the attributes marked as not null on the mapped table Example
Email Validates that field contains a valid email format Example
ExclusionIn Validates that a value is not within a list of possible values Example
InclusionIn Validates that a value is within a list of possible values Example
Numericality Validates that a field has a numeric format Example
Regex Validates that the value of a field matches a regular expression Example
Uniqueness Validates that a field or a combination of a set of fields are not present more than once in the existing records of the related table Example
StringLength Validates the length of a string Example
Url Validates that a value has a valid URL format Example

phalcon: model 验证数据完整性的更多相关文章

  1. ASP.NET MVC Model验证(五)

    ASP.NET MVC Model验证(五) 前言 上篇主要讲解ModelValidatorProvider 和ModelValidator两种类型的自定义实现, 然而在MVC框架中还给我们提供了其它 ...

  2. ASP.NET MVC Model验证(四)

    ASP.NET MVC Model验证(四) 前言 本篇主要讲解ModelValidatorProvider 和ModelValidator两种类型的自定义实现,前者是Model验证提供程序,而Mod ...

  3. ASP.NET MVC Model验证(三)

    ASP.NET MVC Model验证(三) 前言 上篇中说到在MVC框架中默认的Model验证是在哪里验证的,还讲到DefaultModelBinder类型的内部执行的示意图,让大家可以看到默认的M ...

  4. ASP.NET MVC Model验证(二)

    ASP.NET MVC Model验证(二) 前言 上篇内容演示了一个简单的Model验证示例,然后在文中提及到Model验证在MVC框架中默认所处的位置在哪?本篇就是来解决这个问题的,并且会描述一下 ...

  5. ASP.NET MVC Model验证(一)

    ASP.NET MVC Model验证(一) 前言 前面对于Model绑定部分作了大概的介绍,从这章开始就进入Model验证部分了,这个实际上是一个系列的Model的绑定往往都是伴随着验证的.也会在后 ...

  6. ASP.NET MVC5中的Model验证

    Model验证是ASP.NET MVC中的重要部分,它主要用于判断输入的数据类型及值是否符合我们设定的规则,这篇文章就介绍下ASP.NET MVC中Model验证的几种方式. 后台验证 DataAnn ...

  7. ASP.NET MVC的客户端验证:jQuery验证在Model验证中的实现

    在简单了解了Unobtrusive JavaScript形式的验证在jQuery中的编程方式之后,我们来介绍ASP.NET MVC是如何利用它实现客户端验证的.服务端验证最终实现在相应的ModelVa ...

  8. [ASP.NET MVC 小牛之路]16 - Model 验证

    上一篇博文 [ASP.NET MVC 小牛之路]15 - Model Binding 中讲了MVC在Model Binding过程中如何根据用户提交HTTP请求数据创建Model对象.在实际的项目中, ...

  9. Mvc model验证总结

    Model 验证总结 Model 验证总结 1 一.Model 验证标记 1 1.启用客户端验证: 1 2.在 Model 中加入验证标记 2 3 . Model 类中可以添加的验证标记: 3 3.1 ...

随机推荐

  1. canvas动画基础

    setInterval( function(){ render( context ); update(); } , ); window.requestAnimFrame = (function() { ...

  2. PHP去除连续空格

    <?php $note = strip_tags($value['Content']); $note = trim($note); $note = str_replace(" &quo ...

  3. 小扩展大用处,自己扩展一个ForeachRead吧

    是否用过IList的扩展方法 Foreach,而郁闷IEnumerable没有这个扩展?(没用过??用用吧,真的很方便,可以少好几行呢!!) 是否为了有一个索引而不得不用 for 而不能用 forea ...

  4. H5网站借鉴

    http://www.rdinfo.com.cn/index.shtml http://www.winployee.com/ http://www.lkkdesign.com/ http://www. ...

  5. 【leetcode❤python】 Sum of Left Leaves

    #-*- coding: UTF-8 -*- # Definition for a binary tree node.# class TreeNode(object):#     def __init ...

  6. C#中() =>是什么意思

    如题C#中() =>是什么意思,比如 public ICommand AddCommand { get { if (this.addCommand == null) this.addComman ...

  7. cpu,内存,虚拟内存,硬盘,缓存之间是什么关系??

    1.CPU即中央处理器,是英语“Central Processing Unit”的缩写.CPU从内存或缓存中取出指令,放入指令寄存器,并对指令译码分解成一系列的微操作,然后发出各种控制命令,执行微操作 ...

  8. CNV

    CNV: 人类主要是二倍体.如果有些区域出现3个.4个拷贝,那就是扩增了,如果只出现1个拷贝,就是缺失.所以CNV分析是依靠特定位置的测序深度来估算的,先在染色体上划窗,然后看每个窗口的平均测序深度, ...

  9. hdu 2199 (二分)

    链接:http://acm.hdu.edu.cn/showproblem.php?pid=2199 Can you solve this equation? Time Limit: 2000/1000 ...

  10. 3.29考试(HNOI难度)

    一. 城镇 [ town ]   Memory Limit: 128 MB    Time Limit : 1s Description 在 farmer land 上,有 N 个 farmer to ...