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


PHP Validator::stringType方法代码示例

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


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

示例1: isValid

 public function isValid($validation_data)
 {
     $errors = [];
     foreach ($validation_data as $name => $value) {
         if (isset($_REQUEST[$name])) {
             $rules = explode("|", $value);
             foreach ($rules as $rule) {
                 $exploded = explode(":", $rule);
                 switch ($exploded[0]) {
                     case 'min':
                         $min = $exploded[1];
                         if (Valid::stringType()->length($min)->Validate($_REQUEST[$name]) == false) {
                             $errors[] = $name . " must be at least " . $min . " characters long";
                         }
                         break;
                     case 'email':
                         if (Valid::email()->Validate($_REQUEST[$name]) == false) {
                             $errors[] = $name . " must be a valid email ";
                         }
                         break;
                     case 'equalTo':
                         if (Valid::equals($_REQUEST[$name])->Validate($_REQUEST[$exploded[1]]) == false) {
                             $errors[] = "Values do not match";
                         }
                         break;
                     default:
                         //do nothing
                 }
             }
         } else {
             $errors = "No value found";
         }
     }
     return $errors;
 }
开发者ID:pivnicki,项目名称:acme,代码行数:35,代码来源:Validator.php

示例2: set

 /**
  * Saves a setting as a key/value pair
  *
  * Settings specific to fast-forward start with a `ff.` prefix.
  *
  * You can use the constants of this class to avoid looking up the key names.
  *
  * @param string $key   Unique key name.<br>
  *                      Must contain only letters (a-z, A-Z), digits (0-9) and "."
  * @param string $value
  *
  * @throws \Exception
  */
 public function set($key, $value)
 {
     $out = $this->client->getOutput();
     try {
         v::stringType()->alnum('.')->noWhitespace()->notEmpty()->assert($key);
     } catch (NestedValidationException $e) {
         $out->error($e->getFullMessage());
         return;
     }
     $setting = $this->get($key, true);
     if ($setting === null) {
         $setting = new Setting();
         $setting->key = $key;
     }
     $oldValue = $setting->value;
     $setting->value = $value;
     if (!$this->validate($setting)) {
         return;
     }
     if ($oldValue === null) {
         $out->writeln("Inserting new setting:\n{$key} = <options=bold>{$value}</>");
     } elseif ($oldValue !== $value) {
         $out->writeln("Changing setting:\n{$key} = {$oldValue} --> <options=bold>{$value}</>");
     } else {
         $out->writeln("Setting already up-to-date:\n{$key} = {$value}");
     }
     $setting->save();
 }
开发者ID:nochso,项目名称:fast-forward,代码行数:41,代码来源:Settings.php

示例3: isValid

 public function isValid($validation_data)
 {
     $errors = [];
     foreach ($validation_data as $name => $value) {
         $rules = explode("|", $value);
         foreach ($rules as $rule) {
             $exploded = explode(":", $rule);
             switch ($exploded[0]) {
                 case 'min':
                     $min = $exploded[1];
                     if (Valid::stringType()->length($min, null)->Validate($_REQUEST[$name]) == false) {
                         $errors[] = $name . " must be at least " . $min . " characters long!";
                     }
                     break;
                 case 'email':
                     if (Valid::email()->Validate($_REQUEST[$name]) == false) {
                         $errors[] = $name . " must be a valid email address!";
                     }
                     break;
                 case 'equalTo':
                     if (Valid::equals($_REQUEST[$name])->Validate($_REQUEST[$exploded[1]]) == false) {
                         $errors[] = "Value does not match verification value!";
                     }
                     break;
                 default:
                     $errors[] = "No value found!";
             }
         }
     }
     return $errors;
 }
开发者ID:Damien1990,项目名称:acme,代码行数:31,代码来源:Validator.php

示例4: isValid

 public function isValid($validation_data)
 {
     $errors = [];
     foreach ($validation_data as $name => $value) {
         $exploded = explode(":", $value);
         switch ($exploded[0]) {
             case 'min':
                 $min = $exploded[1];
                 if (Valid::stringType()->length($min, null)->Validate($_REQUEST[$name]) == false) {
                     $errors[] = $exploded[2] . " must be at least " . $min . " characters long ";
                 }
                 break;
             case 'email':
                 if (Valid::email()->Validate($_REQUEST[$name]) == false) {
                     $errors[] = "Please enter a valid email";
                 }
                 break;
             case 'equalTo':
                 if (Valid::equals($_REQUEST[$name])->Validate($_REQUEST[$exploded[1]]) == false) {
                     $errors[] = $exploded[2] . " value does not match " . $exploded[3] . " value";
                 }
                 break;
             default:
                 //do nothing
                 $errors[] = "No values found";
         }
     }
     return $errors;
 }
开发者ID:vortexcoaching,项目名称:MQP_Alchemy__Truth,代码行数:29,代码来源:Validator.php

示例5: initRule

 /**
  *  init valid rule
  */
 protected function initRule()
 {
     $this->validRule['id'] = v::numeric();
     $this->validRule['name'] = v::stringType()->length(1, 10);
     $this->validRule['email'] = v::email();
     $this->validRule['sex'] = v::intVal()->between(0, 1);
 }
开发者ID:CrabHo,项目名称:example-lib-profile,代码行数:10,代码来源:ProfileData.php

示例6: charsInMemory

 /**
  * Returns the number of characters in memory after parsing given string.
  * @param string $string
  * @return int
  * @throws ParseException
  */
 public static function charsInMemory($string)
 {
     if (!Validator::stringType()->regex('/".*"/')->validate($string)) {
         throw new ParseException('String must be surrounded by double quotes (")');
     }
     return preg_match_all("/(\\\\\\\\|\\\\\"|\\\\x[[:xdigit:]]{2}|.)/", substr($string, 1, strlen($string) - 2));
 }
开发者ID:hamdrew,项目名称:adventofcode,代码行数:13,代码来源:StringMemoryCalculator.php

示例7: validateName

 protected function validateName()
 {
     $value = v::stringType()->notEmpty()->validate($this->getName());
     if (!$value) {
         msg::showMsg('O campo Nome deve ser preenchido corretamente.' . '<script>focusOn("name");</script>', 'danger');
     }
     return $this;
 }
开发者ID:br-monteiro,项目名称:HTR-Firebird-Framework,代码行数:8,代码来源:AuthValidatorTrait.php

示例8: setCityDistance

 /**
  * Sets the distance between two {@link City}s
  * @param string $cityA name of city
  * @param string $cityB name of city
  * @param int $distance distance between cities
  */
 public function setCityDistance($cityA, $cityB, $distance)
 {
     Validator::stringType()->notBlank()->check($cityA);
     Validator::stringType()->notBlank()->check($cityB);
     Validator::intType()->positive()->check($distance);
     $this->adjacencyMatrix[$cityA][$cityB] = $distance;
     $this->adjacencyMatrix[$cityB][$cityA] = $distance;
 }
开发者ID:hamdrew,项目名称:adventofcode,代码行数:14,代码来源:CityMap.php

示例9: validatePatchVars

 public function validatePatchVars($vars)
 {
     $validations = [v::intVal()->validate($vars['id']), v::stringType()->length(2)->validate($vars['nome']), v::stringType()->length(2)->validate($vars['sobrenome'])];
     if ($vars['nascimento']) {
         $validations[] = v::date()->validate($vars['nascimento']);
     }
     return $validations;
 }
开发者ID:jokeronaldo,项目名称:crud-slim3,代码行数:8,代码来源:Usuario.php

示例10: initRule

 /**
  *  init valid rule
  */
 protected function initRule()
 {
     $this->validRule['uid'] = v::numeric();
     $this->validRule['expid'] = v::numeric();
     $this->validRule['firmName'] = v::stringType()->length(1, 32);
     $this->validRule['indCatNo'] = v::stringType()->length(1, 32);
     $this->validRule['jobName'] = v::stringType()->length(1, 32);
     $this->validRule['areaNo'] = v::stringType()->length(1, 32);
 }
开发者ID:CrabHo,项目名称:example-lib-resume,代码行数:12,代码来源:ExperienceData.php

示例11: testRespectValidatorsAreCallable

 public function testRespectValidatorsAreCallable()
 {
     $filter = v::key('cake', v::stringType());
     static::assertTrue($filter(['cake' => 'a string']));
     static::assertTrue($filter(['cake' => 'a string', 'other']));
     static::assertFalse($filter(['cake' => 12]));
     static::assertFalse($filter([]));
     static::assertFalse($filter(['other']));
 }
开发者ID:graze,项目名称:array-filter,代码行数:9,代码来源:RespectValidationTest.php

示例12: init

 /**
  * Initialise rules
  */
 public function init()
 {
     // name validator
     $this->rules['name'] = Validator::stringType()->setName('Your full name')->notEmpty()->length(1, 32);
     // email validator
     $this->rules['email'] = Validator::email()->setName('Email');
     // comment validator
     $this->rules['comment'] = Validator::stringType()->setName('Comment')->notEmpty();
 }
开发者ID:rlandas,项目名称:UltradataHome,代码行数:12,代码来源:Comment.php

示例13: postValidator

 private function postValidator($post = array())
 {
     try {
         v::stringType()->notEmpty()->length(1, 32)->assert($post['name']);
         v::stringType()->notEmpty()->length(1, 32)->assert($post['password']);
     } catch (vn $exception) {
         $this->MSG->showmsg(nl2br($exception->getFullMessage()));
     }
 }
开发者ID:slion0725,项目名称:admin_ci303,代码行数:9,代码来源:profile.php

示例14: nextMember

 /**
  * Generates the next member in the look-and-say sequence
  * @param string $member the current member
  * @return string
  */
 public function nextMember($member)
 {
     Validator::stringType()->notEmpty()->check($member);
     $next = '';
     preg_match_all("/((\\d)\\2*)/", $member, $matches);
     foreach ($matches[0] as $match) {
         $next .= strval(strlen($match)) . substr($match, 0, 1);
     }
     return $next;
 }
开发者ID:hamdrew,项目名称:adventofcode,代码行数:15,代码来源:LookAndSaySequencer.php

示例15: defineLogin

 public function defineLogin($login)
 {
     $loginValidador = Validator::stringType()->notEmpty()->noWhitespace()->length(8, 120);
     try {
         $loginValidador->check($login);
         $this->login = $login;
     } catch (ValidationException $exception) {
         print_r($exception->getMainMessage());
     }
 }
开发者ID:lmachadosantos,项目名称:autenticacao-oa,代码行数:10,代码来源:Usuario.php


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