本文整理汇总了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;
}
示例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;
}
示例3: validation
public function validation($attributes, $rules = [])
{
if (empty($rules)) {
$rules = $this->rules;
}
return $this->validator->make($attributes, $rules);
}
示例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;
}
示例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());
}
}
示例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());
}
}
示例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);
}
示例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']);
}
示例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());
}
}
示例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());
}
}
示例11: handle
public function handle($data)
{
$validation = $this->validator->make($data, static::$rules);
if ($validation->fails()) {
throw new ValidationException($validation->messages());
}
return true;
}
示例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;
}
示例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;
}
示例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;
}
示例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());
}