• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP Validation\Factory类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了PHP中Illuminate\Validation\Factory的典型用法代码示例。如果您正苦于以下问题:PHP Factory类的具体用法?PHP Factory怎么用?PHP Factory使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



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

 /**
  * Get the validator instance for the request.
  *
  * @param $factory \Illuminate\Validation\Factory
  * @return \Illuminate\Validation\Validator
  */
 public function validator(\Illuminate\Validation\Factory $factory)
 {
     // add 'user_list' attribute if doesn't exist
     if (!$this->request->has('user_list')) {
         $this->merge(['user_list' => []]);
     }
     return $factory->make($this->all(), $this->rules());
 }
开发者ID:mapcompasskey,项目名称:support-ticketing-app,代码行数:14,代码来源:TicketRequest.php


示例9: store

 public function store()
 {
     $validator = $this->validationFactory->make($this->request->except('_token', 'submit'), $this->rules['create']);
     if ($validator->fails()) {
         return $this->redirector->back()->withInput()->withErrors($validator);
     }
     $this->clients->create($this->request->get('name'), $this->request->get('redirect_uri'), (array) $this->request->get('grants'), (array) $this->request->get('scopes'));
     return $this->redirector->route('oauth.clients.index')->with('success', "Client added successfully.");
 }
开发者ID:jorycn,项目名称:oauth2-server-manager,代码行数:9,代码来源:ClientController.php


示例10: store

 /**
  * Store the scope
  *
  * @return \Illuminate\Http\RedirectResponse
  */
 public function store()
 {
     $validator = $this->validationFactory->make($this->request->except('_token', 'submit'), $this->rules['create']);
     if ($validator->fails()) {
         return $this->redirector->back()->withInput()->withErrors($validator);
     }
     $this->scopes->create($this->request->get('id'), $this->request->get('description'));
     return $this->redirector->route('oauth.scopes.index')->with('success', "Scope added successfully.");
 }
开发者ID:jorycn,项目名称:oauth2-server-manager,代码行数:14,代码来源:ScopeController.php


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


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


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


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


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


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


示例17: validation

 public function validation($attributes, $rules = [])
 {
     if (empty($rules)) {
         $rules = $this->rules;
     }
     return $this->validator->make($attributes, $rules);
 }
开发者ID:vinelab,项目名称:agency,代码行数:7,代码来源:Validator.php


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


示例19: validate

 /**
  * Validation method
  * @param \Symfony\Component\HttpFoundation\File\UploadedFile
  * @return \Illuminate\Validation\Validator $validator
  */
 public function validate($csv_file_path)
 {
     // Line endings fix
     ini_set('auto_detect_line_endings', true);
     $csv_extendion = $csv_file_path->getClientOriginalExtension();
     // Open file into memory
     if ($opened_file = fopen($csv_file_path, 'r') === false) {
         throw new Exception('File cannot be opened for reading');
     }
     // Get first row of the file as the header
     $header = fgetcsv($opened_file, 0, ',');
     // Find email column
     $email_column = $this->getColumnNameByValue($header, 'email');
     // Find first_name column
     $first_name_column = $this->getColumnNameByValue($header, 'first_name');
     // Find last_name column
     $last_name_column = $this->getColumnNameByValue($header, 'last_name');
     // Get second row of the file as the first data row
     $data_row = fgetcsv($opened_file, 0, ',');
     // Combine header and first row data
     $first_row = array_combine($header, $data_row);
     // Find email in the email column
     $first_row_email = array_key_exists('email', $first_row) ? $first_row['email'] : '';
     // Find first name in first_name column
     $first_row_first_name = array_key_exists('first_name', $first_row) ? $first_row['first_name'] : '';
     // Find last name in last_name column
     $first_row_last_name = array_key_exists('last_name', $first_row) ? $first_row['last_name'] : '';
     // Close file and free up memory
     fclose($opened_file);
     // Build our validation array
     $validation_array = ['csv_extension' => $csv_extendion, 'email_column' => $email_column, 'first_name_column' => $first_name_column, 'last_name_column' => $last_name_column, 'email' => $first_row_email, 'first_name' => $first_row_first_name, 'last_name' => $first_row_last_name];
     // Return validator object
     return $this->validator->make($validation_array, $this->rules);
 }
开发者ID:antondomratchev,项目名称:CsvImportLaravelExample,代码行数:39,代码来源:CsvImportValidator.php


示例20: validate

 /**
  * @param Ooglee\Domain\CommandBus\ICommand
  * @throws Ooglee\Domain\Validation\ValidationException
  */
 public function validate(ICommand $command)
 {
     $validator = $this->validator->make(['username' => $command->username, 'email' => $command->email, 'password' => $command->password], $this->rules);
     if (!$validator->passes()) {
         throw new ValidationException($validator->errors());
     }
 }
开发者ID:RowlandOti,项目名称:ooglee-usersmodule,代码行数:11,代码来源:CreateUserValidator.php



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP Validation\Validator类代码示例发布时间:2022-05-23
下一篇:
PHP Translation\Translator类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap