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


PHP Factory::make方法代码示例

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


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

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

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

示例3: validation

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

示例4: make

 /**
  * Create a new Validator instance.
  *
  * @param  array  $data
  * @param  array  $rules
  * @param  array  $messages
  * @param  array  $customAttributes
  * @return \Proengsoft\JsValidation\Validator
  */
 public function make(array $data, array $rules, array $messages = [], array $customAttributes = [])
 {
     $validator = $this->factory->make($data, $rules, $messages, $customAttributes);
     $jsValidator = $this->makeJsValidator($validator);
     $this->configureJsRemote($jsValidator);
     return $jsValidator;
 }
开发者ID:Kremon,项目名称:laravel-jsvalidation,代码行数:16,代码来源:Factory.php

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

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

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

示例8: validate

 /**
  * Validate what is passed into the age gate
  *
  * @param array $data
  * @return $this|Validation|\Illuminate\Http\RedirectResponse
  */
 public function validate(array $data)
 {
     $this->validation = $this->validator->make($data, $this->getValidationRules(), $this->getValidationMessages());
     if ($this->validation->fails()) {
         $failed = $this->validation->failed();
         $validExceptTooYoung = array_get($failed, 'dob.Before');
         $canTryAgain = config('laravel-avp.can_try_again');
         $toRedirect = config('laravel-avp.redirect_on_error');
         $redirectURL = config('laravel-avp.redirect_url');
         if (substr($data['dob'], 0, 4) > date('Y')) {
             return redirect()->action('AVPController@agegate')->withErrors($this->validation->messages())->withInput();
         } else {
             if ($validExceptTooYoung && $toRedirect) {
                 return redirect($redirectURL);
             } else {
                 if ($validExceptTooYoung && !$canTryAgain) {
                     $this->session->put('laravel-avp.previous_too_young', true);
                 } else {
                     $this->session->keep('url.intended');
                 }
             }
         }
         return redirect()->action('AVPController@agegate')->withErrors($this->validation->messages())->withInput();
     }
     return $this->setCookie($data['remember']);
 }
开发者ID:fastwebmedia,项目名称:laravel-avp,代码行数:32,代码来源:Validation.php

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

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

示例11: handle

 public function handle($data)
 {
     $validation = $this->validator->make($data, static::$rules);
     if ($validation->fails()) {
         throw new ValidationException($validation->messages());
     }
     return true;
 }
开发者ID:lukaskorl,项目名称:repository,代码行数:8,代码来源:Validator.php

示例12: validate

 /**
  * @param array $formData
  *
  * @return bool
  * @throws FormValidationException
  */
 public function validate(array $formData)
 {
     $this->validation = $this->validator->make($formData, $this->getValidatorRules());
     if ($this->validation->fails()) {
         throw new FormValidationException('Validation Failed!', $this->getValidationErrors());
     }
     return true;
 }
开发者ID:raymondidema,项目名称:formvalidation,代码行数:14,代码来源:FormFactory.php

示例13: validate

 /**
  * @param array $data
  * @param array $rules
  * @param array $messages
  * @return bool
  * @throws ValidationException
  */
 public function validate(array $data, array $rules, $messages = [])
 {
     $validation = $this->validator->make($data, $rules, $messages);
     if ($validation->fails()) {
         throw new ValidationException($validation->messages());
     }
     return true;
 }
开发者ID:jeeftor,项目名称:todo-laravel-angularjs-homestead,代码行数:15,代码来源:GenericValidator.php

示例14: validate

 /**
  * Validate the form data
  *
  * @param array $formData
  * @param null $id
  * @throws \BB\Exceptions\FormValidationException
  * @return boolean
  */
 public function validate(array $formData, $id = null)
 {
     $this->validation = $this->validator->make($formData, $this->getValidationRules(['id' => $id]));
     if ($this->validation->fails()) {
         throw new FormValidationException('Validation failed', $this->getValidationErrors());
     }
     return true;
 }
开发者ID:adamstrawson,项目名称:BBMembershipSystem,代码行数:16,代码来源:FormValidator.php

示例15: test_jalali_after_or_before_replacer_is_applied_with_date_and_format

 public function test_jalali_after_or_before_replacer_is_applied_with_date_and_format()
 {
     $now = '1394-9-15';
     $faNow = StringCleaner::digitsToFarsi($now);
     $validator = $this->factory->make(['graduation_date' => 'garbage'], ['graduation_date' => "required|jalali_after:{$now},Y-m-d|jalali_before:{$now},Y-m-d"]);
     $this->assertTrue($validator->fails());
     $this->assertEquals(['graduation_date' => ["The graduation date must be a Jalali date after {$now}.", "The graduation date must be a Jalali date before {$now}."]], $validator->messages()->toArray());
 }
开发者ID:halaei,项目名称:jalali,代码行数:8,代码来源:JalaliServiceProviderTest.php


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