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


PHP Validator::getData方法代码示例

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


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

示例1: validatePhone

 /**
  * Validates a phone number.
  *
  * @param  string                                     $attribute
  * @param  mixed                                      $value
  * @param  array                                      $parameters
  * @param  \Illuminate\Contracts\Validation\Validator $validator
  * @return bool
  * @throws \Propaganistas\LaravelPhone\Exceptions\InvalidParameterException
  * @throws \Propaganistas\LaravelPhone\Exceptions\NoValidCountryFoundException
  */
 public function validatePhone($attribute, $value, array $parameters, Validator $validator)
 {
     $this->attribute = $attribute;
     $this->data = $validator->getData();
     $this->parameters = array_map('strtoupper', $parameters);
     $this->determineCountries();
     $this->determineTypes();
     $this->checkLeftoverParameters();
     $phoneUtil = PhoneNumberUtil::getInstance();
     // Perform validation.
     foreach ($this->allowedCountries as $country) {
         try {
             // For default countries or country field, the following throws NumberParseException if
             // not parsed correctly against the supplied country.
             // For automatic detection: tries to discover the country code using from the number itself.
             $phoneProto = $phoneUtil->parse($value, $country);
             // For automatic detection, the number should have a country code.
             // Check if type is allowed.
             if ($phoneProto->hasCountryCode() && empty($this->allowedTypes) || in_array($phoneUtil->getNumberType($phoneProto), $this->allowedTypes)) {
                 // Automatic detection:
                 if ($country == 'ZZ') {
                     // Validate if the international phone number is valid for its contained country.
                     return $phoneUtil->isValidNumber($phoneProto);
                 }
                 // Force validation of number against the specified country.
                 return $phoneUtil->isValidNumberForRegion($phoneProto, $country);
             }
         } catch (NumberParseException $e) {
             // Proceed to default validation error.
         }
     }
     return false;
 }
开发者ID:summer11123,项目名称:Laravel-Phone,代码行数:44,代码来源:PhoneValidator.php

示例2: extendUpdate

 /**
  * Extend update validations.
  *
  * @param  \Illuminate\Contracts\Validation\Validator  $validator
  *
  * @return void
  */
 protected function extendUpdate(ValidatorResolver $validator)
 {
     $name = Keyword::make($validator->getData()['name']);
     $validator->after(function (ValidatorResolver $v) use($name) {
         if ($this->isRoleNameGuest($name)) {
             $v->errors()->add('name', trans('orchestra/control::response.roles.reserved-word'));
         }
     });
 }
开发者ID:quetzyg,项目名称:control,代码行数:16,代码来源:Role.php

示例3: filterValidatorData

 /**
  * [filterValidatorData description]
  * @param  Validator $validator [description]
  * @param  [type]    $keys      [description]
  * @return [type]               [description]
  */
 private function filterValidatorData(Validator $validator, $keys)
 {
     $data = $validator->getData();
     return $keys == '*' ? $data : array_keyfilter($data, $keys);
 }
开发者ID:unionbt,项目名称:hanpaimall,代码行数:11,代码来源:ValidatesRequests.php


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