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


PHP Validator::notEmpty方法代码示例

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


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

示例1: initRules

 /**
  * Set items constraints
  *
  * @return void
  */
 public function initRules()
 {
     $this->rules['no_certificado'] = V::numeric()->noWhitespace()->setName('Numero de certificado');
     $this->rules['clave'] = V::notEmpty()->noWhitespace()->setName('Contraseña de la llave privada');
 }
开发者ID:lalocespedes,项目名称:slim-3-simple-api,代码行数:10,代码来源:Csds.php

示例2: index

 public function index($params)
 {
     Validator::notEmpty()->setName('name')->check($params['name']);
     Validator::notEmpty()->setName('password')->check($params['password']);
     $levels = Config::loadData('level');
     $this->render('index.php', ['name' => $params['name']]);
 }
开发者ID:sunpaolo,项目名称:slim3Demo,代码行数:7,代码来源:IndexController.php

示例3: __construct

 public function __construct(Client $client, $key)
 {
     $this->client = $client;
     $this->key = $key;
     $baseUrl = $this->client->getConfig('base_uri');
     Validator::notEmpty()->url()->endsWith('/')->setName("URL for NewRelic's Insights API must be valid and have a trailing slash")->assert($baseUrl);
 }
开发者ID:easytaxibr,项目名称:newrelic,代码行数:7,代码来源:Insights.php

示例4: password

 /**
  * @param   $param
  * @return  string
  * @throws  EntityValidationException
  */
 public function password($param)
 {
     if (!v::notEmpty()->length(2, 100)->validate($param)) {
         throw new EntityValidationException('User', 'password', $param, 'length must be between 2 and 100');
     }
     return $param;
 }
开发者ID:caravanarentals,项目名称:php-wrapper,代码行数:12,代码来源:BaseUserValidation.php

示例5: fuelTypeName

 /**
  * @param   $param
  * @return  string
  * @throws  EntityValidationException
  */
 public function fuelTypeName($param)
 {
     if (!v::notEmpty()->length(1, 100)->validate($param)) {
         throw new EntityValidationException('VehicleCSV', 'fuelTypeName', $param, 'length must be between 1 and 100');
     }
     return $param;
 }
开发者ID:caravanarentals,项目名称:php-wrapper,代码行数:12,代码来源:BaseVehicleCSVFormatValidation.php

示例6: setValidationRules

 protected function setValidationRules($validator)
 {
     $required = new Validator();
     $required->notEmpty();
     $validator->attribute('name', $required);
     $validator->attribute('content', $required);
 }
开发者ID:rikniitt,项目名称:legacy-php-boilerplate,代码行数:7,代码来源:Todo.php

示例7: postalCode

 /**
  * @param   $param
  * @return  string
  * @throws  EntityValidationException
  */
 public function postalCode($param)
 {
     if (!v::notEmpty()->length(2, 100)->validate($param)) {
         throw new EntityValidationException('Address', 'postalCode', $param, 'length must be between 2 and 50');
     }
     return $param;
 }
开发者ID:caravanarentals,项目名称:php-wrapper,代码行数:12,代码来源:BaseAddressValidation.php

示例8: validateField

 private function validateField($parameters, $fieldName)
 {
     if (v::key($fieldName)->validate($parameters)) {
         if (v::notEmpty()->validate($parameters[$fieldName])) {
             return true;
         }
     }
     return false;
 }
开发者ID:marcoescudeiro,项目名称:erede-acquiring-php,代码行数:9,代码来源:TransactionCreditFindValidator.php

示例9: uniqueReference

 /**
  * @param   $param
  * @return  string
  * @throws  EntityValidationException
  */
 public function uniqueReference($param)
 {
     if (empty($param) || is_null($param)) {
         return $param;
     }
     if (!v::notEmpty()->length(1, 100)->validate((string) $param)) {
         throw new EntityValidationException('Vendor', 'uniqueReference', $param, 'length must be between 1 and 100');
     }
     return $param;
 }
开发者ID:caravanarentals,项目名称:php-wrapper,代码行数:15,代码来源:BaseVendorValidation.php

示例10: postChild

 protected function postChild($categoryId)
 {
     try {
         v::arr()->key('name', v::string()->notEmpty()->length(1, 300))->key('parent_category', v::notEmpty()->int()->equals($categoryId))->assert($_POST);
         $newCategory = (object) (['id' => null] + $_POST);
         $this->collection->persist($newCategory);
         $this->collection->flush();
         header('HTTP/1.1 303 See Other');
         header('Location: ' . $_SERVER['REQUEST_URI']);
     } catch (NestedValidationExceptionInterface $e) {
         return ['category/editCategory' => $editProduct, 'messages' => $e->findMessages(['name' => 'Name must have between 1 and 300 chars'])];
     }
 }
开发者ID:supercluster,项目名称:catalog,代码行数:13,代码来源:Edit.php

示例11: validateAddress

 public function validateAddress($address)
 {
     //@TODO: properly check all types.. strings need to be double checked for alnum, cause of typecasting.
     $rules = v::key('firstname', v::notEmpty()->setName('First name'))->key('lastname', v::notEmpty()->setName('Last name'))->key('address', v::alnum(".,-'")->notEmpty()->setName('Address'))->key('secondary_address', v::when(v::notEmpty(), v::alnum(".,-'"), v::alwaysValid())->setName('Address 2'))->key('city', v::alnum()->notEmpty()->setName('City'))->key('state', v::alnum()->notEmpty()->setName('State'))->key('zip', v::when(v::notEmpty(), v::postalCode('US'), v::alwaysValid())->notEmpty()->setName('Zipcode'));
     if ($rules->validate($address)) {
         return true;
     }
     try {
         $rules->check($address);
     } catch (ValidationExceptionInterface $exception) {
         //            $this->error = $exception->getMainMessage();
     }
     return false;
 }
开发者ID:alldigitalrewards,项目名称:marketplace,代码行数:14,代码来源:ValidationTrait.php

示例12: test_findMessages_should_apply_templates_to_flattened_messages

 public function test_findMessages_should_apply_templates_to_flattened_messages()
 {
     $stringMax256 = v::string()->length(5, 256);
     $alnumDot = v::alnum('.');
     $stringMin8 = v::string()->length(8, null);
     $v = v::allOf(v::attribute('first_name', $stringMax256)->setName('First Name'), v::attribute('last_name', $stringMax256)->setName('Last Name'), v::attribute('desired_login', $alnumDot)->setName('Desired Login'), v::attribute('password', $stringMin8)->setName('Password'), v::attribute('password_confirmation', $stringMin8)->setName('Password Confirmation'), v::attribute('stay_signedin', v::notEmpty())->setName('Stay signed in'), v::attribute('enable_webhistory', v::notEmpty())->setName('Enabled Web History'), v::attribute('security_question', $stringMax256)->setName('Security Question'))->setName('Validation Form');
     try {
         $v->assert((object) array('first_name' => 'fiif', 'last_name' => null, 'desired_login' => null, 'password' => null, 'password_confirmation' => null, 'stay_signedin' => null, 'enable_webhistory' => null, 'security_question' => null));
     } catch (ValidationException $e) {
         $messages = $e->findMessages(array('allOf' => 'Invalid {{name}}', 'first_name.length' => 'Invalid length for {{name}} {{input}}'));
         $this->assertEquals($messages['allOf'], 'Invalid Validation Form');
         $this->assertEquals($messages['first_name_length'], 'Invalid length for "fiif" fiif');
     }
 }
开发者ID:vituhugo,项目名称:webservice,代码行数:14,代码来源:AbstractNestedExceptionTest.php

示例13: __construct

 public function __construct($data)
 {
     parent::__construct();
     $this->data = $data;
     $this->fields = array('firstname' => array('value' => $this->data['firstname'], 'validators' => array('notEmpty'), 'errors' => array('Firstname is empty')), 'email' => array('value' => $this->data['email'], 'validators' => array('email', 'notEmpty'), 'errors' => array('Email is not valid', 'Email is empty')), 'url' => array('value' => $this->data['url'], 'validators' => array('notEmpty', 'url'), 'errors' => array('Url is empty', 'Url is not valid')), 'cv' => array('value' => $_FILES['cv'], 'validators' => function () {
         return v::exists()->validate($_FILES['cv']["tmp_name"]);
     }, 'errors' => array('File is empty')), 'content' => array('value' => $this->data['content'], 'validators' => function ($value) {
         return v::when(v::int(), v::positive(), v::notEmpty())->validate($value);
     }, 'errors' => array('content is not valid')), 'int' => array('value' => $this->data['int'], 'validators' => function ($value) {
         return v::allOf(v::int(), v::positive(), v::notEmpty())->validate($value);
     }, 'errors' => array('int is not valid')), 'uppercase' => array('value' => '', 'validators' => function ($value) {
         return v::string()->uppercase()->validate($value);
     }, 'errors' => array('uppercase is not valid')));
 }
开发者ID:ddelor,项目名称:gallery-wp-theme,代码行数:14,代码来源:FormTest.php

示例14: validate

 public function validate($addr)
 {
     $this->clearErrors();
     // Do our special validations first
     // State should only be set for the US
     if ($addr->getField('Country') != 'US' && v::notEmpty()->validate($addr->getField('State'))) {
         $this->addError('State', $this->STATE_ONLY_FOR_US);
     }
     // Country must be an ISO3166-1 Country Code
     if (!array_key_exists($addr->getField('Country'), Iso3166::get())) {
         $this->addError('Country', $this->COUNTRY_VALID_CODE);
     }
     // Perform some general validations and return ourself
     return parent::validate($addr);
 }
开发者ID:academe,项目名称:sagepay,代码行数:15,代码来源:Address.php

示例15: login

 /**
  * @RPC\Route("/api/auth/login")
  * @RPC\Method("POST")
  */
 public function login()
 {
     $credentials = json_decode($this->request->getContent(), true);
     try {
         v::create()->key('email', v::notEmpty())->key('password', v::notEmpty())->assert($credentials);
     } catch (ValidationException $e) {
         $errors = $e->findMessages(['email', 'password']);
         throw new \pmill\Doctrine\Rest\Exception\ValidationException($errors);
     }
     $password = $credentials['password'];
     unset($credentials['password']);
     /** @var User $user */
     $user = $this->authenticationService->authenticateWithCredentials(User::class, $credentials, $password);
     $token = $this->authenticationService->generateTokenFromObject($user);
     return ['token' => $token];
 }
开发者ID:pmill,项目名称:doctrine-rest-api,代码行数:20,代码来源:AuthenticationController.php


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