当前位置: 首页>>代码示例>>PHP>>正文


PHP Validator::buildRule方法代码示例

本文整理汇总了PHP中Respect\Validation\Validator::buildRule方法的典型用法代码示例。如果您正苦于以下问题:PHP Validator::buildRule方法的具体用法?PHP Validator::buildRule怎么用?PHP Validator::buildRule使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Respect\Validation\Validator的用法示例。


在下文中一共展示了Validator::buildRule方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: addRule

 public function addRule($validator, $arguments = array())
 {
     if (!$validator instanceof Validatable) {
         $this->appendRule(Validator::buildRule($validator, $arguments));
     } else {
         $this->appendRule($validator);
     }
     return $this;
 }
开发者ID:nowsolutions,项目名称:Validation,代码行数:9,代码来源:AbstractComposite.php

示例2: validateField

 /**
  * Validate a field's value with a given $rule
  * 
  * @param $value  mixed  Value to validate
  * @param $rule  mixed  Rule(s) to use for validation
  * @return bool
  */
 public static function validateField($value, $rule)
 {
     // only validate non-empty fields
     if ($value == "") {
         return true;
     }
     // validate
     $validator = new Validator();
     // create rules
     if (!is_array($rule)) {
         $validator->addRule(Validator::buildRule($rule));
     } else {
         foreach ($rule as $rule_key => $params) {
             $params = Helper::ensureArray($params);
             $validator->addRule(Validator::buildRule($rule_key, $params));
         }
     }
     return $validator->validate($value);
 }
开发者ID:andorpandor,项目名称:git-deploy.eu2.frbit.com-yr-prototype,代码行数:26,代码来源:form.php

示例3: handleValidationRule

 /**
  * Smart method to process fields, regardless of data type
  *
  * @param string  $field  Field to validate
  * @param mixed  $rule  Rule (or rules) to chain and validate with
  * @return bool
  */
 private function handleValidationRule($field, $rule)
 {
     if ($field == '') {
         return true;
     }
     # only validate non-empty fields.
     $spawn = new v();
     if (!is_array($rule)) {
         $spawn->addRule(v::buildRule($rule));
     } else {
         foreach ($rule as $rule_key => $params) {
             $params = !is_array($params) ? (array) $params : $params;
             # make sure params are an array
             $spawn->addRule(v::buildRule($rule_key, $params));
         }
     }
     return $spawn->validate($field);
 }
开发者ID:jeffreyDcreative,项目名称:gkp,代码行数:25,代码来源:hooks.raven.php


注:本文中的Respect\Validation\Validator::buildRule方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。