當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Validation\Factory類代碼示例

本文整理匯總了PHP中Illuminate\Validation\Factory的典型用法代碼示例。如果您正苦於以下問題:PHP Factory類的具體用法?PHP Factory怎麽用?PHP Factory使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了Factory類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: setValidator

 protected function setValidator()
 {
     $filesystem = new FileLoader(new Filesystem(), CONFIG_DIR . DIRECTORY_SEPARATOR . 'langs');
     $translator = new Translator($filesystem, Main::$app->web->get('locale', false) ?: 'en');
     $this->validator = new ValidatorFactory($translator);
     $verifier = new DatabasePresenceVerifier($this->capsule->getDatabaseManager());
     $this->validator->setPresenceVerifier($verifier);
 }
開發者ID:xandros15,項目名稱:aigisu,代碼行數:8,代碼來源:Connection.php

示例2: extendValidator

 /**
  * Extend the Validator.
  *
  * @param Factory $factory
  */
 protected function extendValidator(Factory $factory)
 {
     $factory->replacer('required_if_has', function ($message, $attribute, $rule, $parameters) {
         return $this->setFieldsAndValues($message, $attribute, $rule, $parameters);
     });
     $factory->replacer('required_if_not', function ($message, $attribute, $rule, $parameters) {
         return $this->setFieldsAndValues($message, $attribute, $rule, $parameters);
     });
     /////////////////////
     // Required if NOT //
     /////////////////////
     $factory->extendImplicit('required_if_not', function ($attribute, $value, $parameters = []) {
         $input = $this->input();
         $field = $parameters[0];
         $fieldValue = $parameters[1];
         // If the field is not set, default to true
         if (!array_key_exists($field, $input)) {
             return true;
         }
         return $input[$field] !== $fieldValue ? array_key_exists($attribute, $input) : true;
     }, "La question ':attribute' est requise lorsque la question ':field' n'est pas ':value' !");
     //////////////////////////////////
     // If checkbox contains a value //
     //////////////////////////////////
     $factory->extendImplicit('required_if_has', function ($attribute, $value, $parameters = []) {
         $input = $this->input();
         $field = $parameters[0];
         $fieldValue = $parameters[1];
         // If the field is not set, default to true
         if (!array_key_exists($field, $input)) {
             return true;
         }
         return array_key_exists($fieldValue, $input[$field]) ? array_key_exists($attribute, $input) : true;
     }, "La question ':attribute' est requise lorsque la question ':field' contient ':value' !");
 }
開發者ID:rleger,項目名稱:TheseEcho,代碼行數:40,代碼來源:ValidatorExtentionsTrait.php

示例3: register

 public function register(Application $app)
 {
     $core = $app;
     $app['illuminate'] = new Container();
     $app['illuminate']['config'] = array('cache.driver' => 'memcached', 'cache.memcached' => array(array('host' => 'localhost', 'port' => '11211')));
     $app['illuminate']->bindShared('validator', function ($app) use($core) {
         $validator = new Factory($core['translator'], $app);
         // The validation presence verifier is responsible for determining the existence
         // of values in a given data collection, typically a relational database or
         // other persistent data stores. And it is used to check for uniqueness.
         if (isset($app['validation.presence'])) {
             $validator->setPresenceVerifier($app['validation.presence']);
         }
         return $validator;
     });
     $app['illuminate']->bindShared('cache', function ($app) {
         return new CacheManager($app);
     });
     $app['illuminate']->bindShared('cache.store', function ($app) {
         return $app['cache']->driver();
     });
     $app['illuminate']->bindShared('memcached.connector', function () {
         return new MemcachedConnector();
     });
 }
開發者ID:vespakoen,項目名稱:bolt-core,代碼行數:25,代碼來源:IlluminateServiceProvider.php

示例4: __construct

 public function __construct(Factory $factory)
 {
     //Custom Validator Rut
     $factory->extend('rut_valid', function ($attribute, $value, $parameters) {
         return Rut::check($value);
     }, 'El campo Rut no tiene un formato válido');
 }
開發者ID:ProyectoSanClemente,項目名稱:proyectoapi5.1,代碼行數:7,代碼來源:CreateUsuarioRequest.php

示例5: __construct

 /**
  * Overwrite the parent constructor to define a new validator.
  *
  * @param  Factory $factory
  * @return void
  * @SuppressWarnings(PHPMD.UnusedLocalVariable)
  */
 public function __construct(Factory $factory)
 {
     $factory->extend('repository', function ($attribute, $value, $parameters) {
         if (preg_match('/^(ssh|git|https?):\\/\\//', $value)) {
             // Plain old git repo
             return true;
         }
         if (preg_match('/^(.*)@(.*):(.*)\\/(.*)\\.git/', $value)) {
             // Gitlab
             return true;
         }
         /*
         TODO: improve these regexs, using the following stolen from PHPCI (sorry Dan!)
         
         'ssh': /git\@github\.com\:([a-zA-Z0-9_\-]+\/[a-zA-Z0-9_\-]+)\.git/,
         'git': /git\:\/\/github.com\/([a-zA-Z0-9_\-]+\/[a-zA-Z0-9_\-]+)\.git/,
         'http': /https\:\/\/github\.com\/([a-zA-Z0-9_\-]+\/[a-zA-Z0-9_\-]+)(\.git)?/
         */
         if (preg_match('/^[a-zA-Z0-9_\\-]+\\/[a-zA-Z0-9_\\-\\.]+$/', $value)) {
             // Github
             return true;
         }
         /*
         'ssh': /git\@bitbucket\.org\:([a-zA-Z0-9_\-]+\/[a-zA-Z0-9_\-]+)\.git/,
         'http': /https\:\/\/[a-zA-Z0-9_\-]+\@bitbucket.org\/([a-zA-Z0-9_\-]+\/[a-zA-Z0-9_\-]+)\.git/,
         'anon': /https\:\/\/bitbucket.org\/([a-zA-Z0-9_\-]+\/[a-zA-Z0-9_\-]+)(\.git)?/
         */
         if (preg_match('/^[a-zA-Z0-9_\\-]+\\/[a-zA-Z0-9_\\-\\.]+$/', $value)) {
             // Bitbucket
             return true;
         }
         return false;
     });
 }
開發者ID:devLopez,項目名稱:deployer-1,代碼行數:41,代碼來源:StoreProjectRequest.php

示例6: register

 /**
  * Register the service provider.
  *
  * @return void
  */
 public function register()
 {
     $this->mergeConfigFrom(__DIR__ . '/../config/captcha.php', 'mews.captcha');
     /**
      * @param $app
      * @return Captcha
      */
     $this->app->bind('captcha', function ($app) {
         return new Captcha($app['Illuminate\\Filesystem\\Filesystem'], $app['Illuminate\\Config\\Repository'], $app['Intervention\\Image\\ImageManager'], $app['Illuminate\\Session\\Store'], $app['Illuminate\\Hashing\\BcryptHasher'], $app['Illuminate\\Support\\Str']);
     });
     /**
      * @param Captcha $captcha
      * @param $config
      * @return \Intervention\Image\ImageManager
      */
     $this->app['router']->get('captcha/{config?}', 'Chekun\\Captcha\\CaptchaController@draw');
     $this->app['validator'] = $this->app->share(function ($app) {
         $validator = new Factory($app['translator']);
         $validator->setPresenceVerifier($this->app['validation.presence']);
         $validator->resolver(function ($translator, $data, $rules, $messages) {
             return new CaptchaValidator($translator, $data, $rules, $messages);
         });
         return $validator;
     });
 }
開發者ID:chekun,項目名稱:captcha,代碼行數:30,代碼來源:CaptchaServiceProvider.php

示例7: __construct

 /**
  * Overwrite the parent constructor to define a new validator.
  *
  * @param  Factory $factory
  * @return void
  * @SuppressWarnings(PHPMD.UnusedLocalVariable)
  */
 public function __construct(Factory $factory)
 {
     $factory->extend('channel', function ($attribute, $value, $parameters) {
         $first_character = substr($value, 0, 1);
         return ($first_character === '#' || $first_character === '@') && strlen($value) > 1;
     });
 }
開發者ID:BlueBayTravel,項目名稱:deployer,代碼行數:14,代碼來源:StoreNotificationRequest.php

示例8: validate

 /**
  * @param \Hex\CommandBus\CommandInterface $command
  * @throws \Hex\Validation\ValidationException
  */
 public function validate(CommandInterface $command)
 {
     $validator = $this->validator->make(['subject' => $command->subject, 'name' => $command->name, 'email' => $command->email, 'category_id' => $command->category_id, 'staffer_id' => $command->staffer_id, 'message' => $command->message], $this->rules);
     if (!$validator->passes()) {
         throw new ValidationException($validator->errors());
     }
 }
開發者ID:yuzic,項目名稱:hexagonal-php,代碼行數:11,代碼來源:CreateTicketValidator.php

示例9: setLines

 /**
  * Set the language lines used by the translator.
  *
  * @param  array $lines
  * @return void
  */
 public function setLines(array $lines)
 {
     $translator = $this->factory->getTranslator();
     if ($translator instanceof Translator) {
         $translator->setLines($lines);
     }
 }
開發者ID:hazzardweb,項目名稱:validation,代碼行數:13,代碼來源:Validator.php

示例10: makeValidator

 /**
  * Make a new validator instance for this model.
  *
  * @param array $attributes
  * @return \Illuminate\Validation\Validator
  */
 protected function makeValidator(array $attributes)
 {
     $rules = array_only($this->getRules(), array_keys($attributes));
     $validator = $this->validator->make($attributes, $rules, $this->getMessages());
     $this->events->fire(new ConfigureValidator($this, $validator));
     return $validator;
 }
開發者ID:asifalimd,項目名稱:core,代碼行數:13,代碼來源:AbstractValidator.php

示例11: validate

 /**
  * @param Ooglee\Domain\CommandBus\ICommand
  * @throws Ooglee\Domain\Validation\ValidationException
  */
 public function validate(ICommand $command)
 {
     $validator = $this->validator->make(['title' => $command->title, 'slug' => $command->slug, 'main_image' => $command->main_image, 'summary' => $command->summary, 'content' => $command->content], $this->rules);
     if (!$validator->passes()) {
         throw new ValidationException($validator->errors());
     }
 }
開發者ID:RowlandOti,項目名稱:ooglee-blogmodule,代碼行數:11,代碼來源:TypeValidator.php

示例12: validate

 /**
  * Validates the address lookup input.
  *
  * @param array $data
  * @throws ValidationException
  */
 public function validate(array $data = [])
 {
     $validation = $this->validator->make($data, $this->rules);
     if ($validation->fails()) {
         throw new ValidationException($validation->errors());
     }
 }
開發者ID:hannenijhuis,項目名稱:laravel-postcode-nl,代碼行數:13,代碼來源:AddressLookupValidator.php

示例13: extendValidator

 /**
  * Extend validator.
  *
  * @param  string         $name
  * @param  string         $class
  * @param  \Closure|null  $replacer
  */
 private function extendValidator($name, $class, Closure $replacer = null)
 {
     $this->validator->extend($name, $class . '@validate' . studly_case($name));
     if (!is_null($replacer)) {
         $this->validator->replacer($name, $replacer);
     }
 }
開發者ID:arcanesoft,項目名稱:auth,代碼行數:14,代碼來源:ValidatorServiceProvider.php

示例14: validation

 public function validation($attributes, $rules = [])
 {
     if (empty($rules)) {
         $rules = $this->rules;
     }
     return $this->validator->make($attributes, $rules);
 }
開發者ID:vinelab,項目名稱:agency,代碼行數:7,代碼來源:Validator.php

示例15: makeValidator

 /**
  * Make a new validator instance for this model.
  *
  * @return \Illuminate\Validation\Validator
  */
 protected function makeValidator()
 {
     $rules = $this->expandUniqueRules($this->rules);
     $validator = static::$validator->make($this->getAttributes(), $rules);
     event(new ModelValidator($this, $validator));
     return $validator;
 }
開發者ID:redstarxz,項目名稱:flarumone,代碼行數:12,代碼來源:ValidatesBeforeSave.php


注:本文中的Illuminate\Validation\Factory類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。