phalcon: model 验证数据完整性

Posted 穆晟铭

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了phalcon: model 验证数据完整性相关的知识,希望对你有一定的参考价值。

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:

NameExplanationExample
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 验证数据完整性的主要内容,如果未能解决你的问题,请参考以下文章

使用 phalcon 检查数据库中是不是存在电子邮件

phalcon:非空字段不能在beforeCreate赋值

phalcon:数据库分库,读写分离,负载均衡 系统方法执行顺序

Phalcon学习-model

致命错误:未捕获的异常“Phalcon\Mvc\Model\Exception”与消息“语法错误,意外令牌>,

phalcon: 按年分表的model怎么建?table2017,table2018...相同名的分表模型怎么建