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


PHP Validator::equals方法代码示例

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


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

示例3: 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

示例4: 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::alpha()->length($min)->Validate($_POST[$name]) == false) {
                         $errors[] = $name . " must be at least " . $exploded[1] . " characters long!";
                     }
                     break;
                 case 'email':
                     if (Valid::email()->validate($_POST[$name]) == false) {
                         $errors[] = $name . " must be a valid email address!";
                     }
                     break;
                 case 'equalTo':
                     if (Valid::equals($_POST[$name])->validate($_POST[$exploded[1]]) == false) {
                         $errors[] = $name . "'s don't match!";
                     }
                     break;
                 default:
                     $errors[] = "No value found!";
                     break;
             }
         }
     }
     return $errors;
 }
开发者ID:jurajvuk,项目名称:acme,代码行数:32,代码来源:Validator.php

示例5: post

 public function post($request, $response, $service, $app)
 {
     Auth::restrictAccess('anonymous');
     $app->users = new Users();
     $app->passwordResets = new PasswordResets();
     $email = $request->param('email');
     $token = $request->param('token');
     $passwordReset = self::validatePasswordResetRequest($email, $token);
     $body = json_decode($request->body());
     $newPassword = $body->newPassword;
     $confirmPassword = $body->confirmPassword;
     if (!v::length(6, 55)->validate($newPassword)) {
         return 'password 1 dont comply';
     }
     if (!v::length(6, 55)->validate($confirmPassword)) {
         return 'password 2 dont comply';
     }
     if (!v::equals($newPassword)->validate($confirmPassword)) {
         return 'passwords dont match';
     }
     // user update password
     $app->users->updatePassword($passwordReset['userId'], $newPassword);
     // delete the passwordReset row after use
     $app->passwordResets->destroy($passwordReset['id']);
 }
开发者ID:aodkrisda,项目名称:slim3-api,代码行数:25,代码来源:PasswordResetController.php

示例6: create

 /**
  * Creates a new {@link LightInstruction}, verifying the action is valid and exactly two
  * coordinates have been given.
  *
  * @param int $action {@link LightInstructionAction}
  * @param Coordinate[] $coordinatePair two coordinates
  * @return LightInstruction
  * @throws \InvalidArgumentException
  */
 public static function create($action, array $coordinatePair)
 {
     v::oneOf(v::equals(LightInstructionAction::TURN_ON), v::equals(LightInstructionAction::TURN_OFF), v::equals(LightInstructionAction::TOGGLE))->check($action);
     v::length(2, 2)->check($coordinatePair);
     v::each(v::instance('\\Hamdrew\\AdventOfCode\\Day6\\Coordinate'))->check($coordinatePair);
     return new LightInstruction($action, $coordinatePair);
 }
开发者ID:hamdrew,项目名称:adventofcode,代码行数:16,代码来源:LightInstructionFactory.php

示例7: 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::string()->length($min, null)->Validate($_REQUEST[$name]) == false) {
                         $errors[] = $name . " must be at least " . $min . " characters long.";
                     }
                     break;
                 case 'max':
                     $max = $exploded[1];
                     if (Valid::string()->length(null, $max)->Validate($_REQUEST[$name]) == false) {
                         $errors[] = $name . " cannot be more than " . $max . " characters long.";
                     }
                     break;
                 case 'email':
                     if (Valid::email()->Validate($_REQUEST[$name]) == false) {
                         $errors[] = "Must be a valid email address.";
                     }
                     break;
                 case 'equalTo':
                     if (Valid::equals($_REQUEST[$name])->Validate($_REQUEST[$exploded[1]]) == false) {
                         $errors[] = "Values do not match.";
                     }
                     break;
                     // check to see if already exists in database
                 // check to see if already exists in database
                 case 'unique':
                     $model = "Acme\\models\\" . $exploded[1];
                     $table = new $model();
                     $results = $table::where($name, '=', $_REQUEST[$name])->get();
                     foreach ($results as $item) {
                         $errors[] = $_REQUEST[$name] . " already exists in this system.";
                     }
                     break;
                 default:
                     $errors[] = "No value found.";
             }
         }
     }
     return $errors;
 }
开发者ID:Notesong,项目名称:acme,代码行数:47,代码来源:Validator.php

示例8: 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)->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 the verification value';
                     }
                     break;
                 case 'unique':
                     $model = "Acme\\models\\" . $exploded[1];
                     $table = new $model();
                     $results = $table->where($name, '=', $_REQUEST[$name])->get();
                     foreach ($results as $result) {
                         $errors[] = $_REQUEST[$name] . " already exists in this system!";
                     }
                     break;
                 default:
                     $errors = 'No value found';
                     break;
             }
         }
     }
     return $errors;
 }
开发者ID:pagchen,项目名称:acme,代码行数:40,代码来源:Validator.php

示例9: check

 /**
  * @param $validation_data
  * @return array
  */
 public function check($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)->Validate($this->request->input($name)) == false) {
                         $errors[] = $name . " must be at least " . $min . " characters long!";
                     }
                     break;
                 case 'email':
                     if (Valid::email()->Validate($this->request->input($name)) == false) {
                         $errors[] = $name . " must be a valid email!";
                     }
                     break;
                 case 'equalTo':
                     if (Valid::equals($this->request->input($name))->Validate($this->request->input($exploded[1])) == false) {
                         $errors[] = "Value does not match verification value!";
                     }
                     break;
                 case 'unique':
                     $model = "Acme\\models\\" . $exploded[1];
                     $table = new $model();
                     $results = $this->getRows($table, $name);
                     foreach ($results as $item) {
                         $errors[] = $this->request->input($name) . " already exists in this system!";
                     }
                     break;
                 default:
                     $errors[] = "No value found!";
             }
         }
     }
     return $errors;
 }
开发者ID:tcs-udemy,项目名称:introduction-to-unit-testing,代码行数:43,代码来源:Validator.php

示例10: equals

 /**
  * 检测是否为特定值
  *
  * @param  string $value
  * @param  string $required 要比较的值
  * @param  bool   $strict
  * @return bool
  */
 public static function equals($value, $required, $strict = false)
 {
     return Validator::equals($value, $strict)->validate($required);
 }
开发者ID:tourze,项目名称:base,代码行数:12,代码来源:Valid.php

示例11: validateForm

 private function validateForm($params)
 {
     if (!v::notEmpty()->validate($params['first_name'])) {
         return ['isValid' => false, 'message' => 'First name is required.'];
     }
     if (!v::notEmpty()->validate($params['last_name'])) {
         return ['isValid' => false, 'message' => 'Last name is required.'];
     }
     if (!v::notEmpty()->validate($params['email'])) {
         return ['isValid' => false, 'message' => 'Email is required.'];
     }
     if (!v::email()->validate($params['email'])) {
         return ['isValid' => false, 'message' => 'Business Email should be a valid email.'];
     }
     if (!v::notEmpty()->validate($params['password'])) {
         return ['isValid' => false, 'message' => 'Password is required.'];
     }
     if (!v::equals($params['confirm_password'])->validate($params['password'])) {
         return ['isValid' => false, 'message' => 'Password mismatched.'];
     }
     return ['isValid' => true, 'message' => 'User saved.'];
 }
开发者ID:emman-bautista,项目名称:mvc-modular-slim,代码行数:22,代码来源:UserController.php

示例12: function

<?php

require_once ROOT . 'models/model.php';
use Respect\Validation\Validator as v;
$validateSignup = function () use($app) {
    $req = $app->request();
    $data = $req->post();
    $validator = v::key('domain', v::domain()->notEmpty())->key('username', v::string()->notEmpty()->length(1, 32))->key('email', v::email()->notEmpty())->key('nick', v::string()->notEmpty()->length(1, 32))->key('password', v::string()->notEmpty()->length(6, 20))->key('password_confirm', v::equals($data['password'])->notEmpty());
    try {
        $validator->assert($data);
    } catch (\InvalidArgumentException $e) {
        $errors = $e->findMessages(array('domain' => '网站域名不能为空', 'username' => '账户只能是英文字符和数字', 'email' => '邮箱格式不正确', 'nick' => '用户名称不能为空', 'password' => '密码不能少于6个字符', 'password_confirm' => '两次输入的密码不一致'));
        $app->flash('errors', $errors);
        $app->redirect(SITE_URL . '/signup');
    }
};
/**
 *-------------------------------------------
 * User Signup
 *-------------------------------------------
 */
$app->get('/signup', function () use($app) {
    $app->render("signup.html");
})->name('signup');
$app->post('/signup', $validateSignup, function () use($app) {
    // $this->halt('500', "Signup Not Supported Now");
    $req = $app->request();
    $data = $req->post();
    $error = null;
    $user = ORM::forTable('users')->where('email', $data['email'])->findOne();
    if ($user) {
开发者ID:xintao222,项目名称:livehub,代码行数:31,代码来源:member.php

示例13: validateEqualTo

 private function validateEqualTo($item, $value, $parameter)
 {
     if (Valid::equals($_POST[$item])->validate($_POST[$parameter]) == false) {
         $this->errors[] = $this->formatName($item) . ' field does not match the ' . $this->formatName($parameter) . ' field.';
     }
 }
开发者ID:marious,项目名称:modern,代码行数:6,代码来源:Validator.php

示例14: XenResponse

 /**
  * This parse the xml response and return the response obj
  *
  * @param mixed $response, 
  *         
  *
  * @return XenResponse
  */
 function xenrpc_parseresponse($response)
 {
     if (!Validator::arr()->validate($response) && !Validator::key('Status')->validate($request)) {
         return new XenResponse($response);
     } else {
         if (Validator::key('Status', Validator::equals('Success'))->validate($response)) {
             return new XenResponse($response);
         } else {
             if ($response['ErrorDescription'][0] == 'SESSION_INVALID') {
                 $response = $this->xenrpc_request($url, $this->xenrpc_method('session.login_with_password', array($this->_user, $this->_password, '1.3.1')));
                 if (Validator::arr()->validate($response) && Validator::key('Status', Validator::equals('Success'))->validate($response)) {
                     $this->_setSessionId($response['Value']);
                 } else {
                     return new XenResponse($response);
                 }
             } else {
                 return new XenResponse($response);
             }
         }
     }
     return new XenResponse($response);
 }
开发者ID:sircamp,项目名称:xenapi,代码行数:30,代码来源:XenConnection.php


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