当前位置: 首页>>代码示例>>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;未经允许,请勿转载。