當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。