Skip to content

Commit

Permalink
[8.x] Remove illuminate/foundation dependency from Password validation (
Browse files Browse the repository at this point in the history
#37648)

* Replace foundation translate call

* Update Password.php

Co-authored-by: Taylor Otwell <taylor@laravel.com>
  • Loading branch information
netpok and taylorotwell authored Jun 10, 2021
1 parent 42c6ca7 commit 45262e6
Showing 1 changed file with 23 additions and 2 deletions.
25 changes: 23 additions & 2 deletions src/Illuminate/Validation/Rules/Password.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,23 @@
use Illuminate\Contracts\Validation\DataAwareRule;
use Illuminate\Contracts\Validation\Rule;
use Illuminate\Contracts\Validation\UncompromisedVerifier;
use Illuminate\Contracts\Validation\ValidatorAwareRule;
use Illuminate\Support\Arr;
use Illuminate\Support\Facades\Validator;
use Illuminate\Support\Traits\Conditionable;
use InvalidArgumentException;

class Password implements Rule, DataAwareRule
class Password implements Rule, DataAwareRule, ValidatorAwareRule
{
use Conditionable;

/**
* The validator performing the validation.
*
* @var \Illuminate\Contracts\Validation\Validator
*/
protected $validator;

/**
* The data under validation.
*
Expand Down Expand Up @@ -149,6 +157,19 @@ public static function sometimes()
return ['sometimes', static::default()];
}

/**
* Set the performing validator.
*
* @param \Illuminate\Contracts\Validation\Validator $validator
* @return $this
*/
public function setValidator($validator)
{
$this->validator = $validator;

return $this;
}

/**
* Set the data under validation.
*
Expand Down Expand Up @@ -306,7 +327,7 @@ public function message()
protected function fail($messages)
{
$messages = collect(Arr::wrap($messages))->map(function ($message) {
return __($message);
return $this->validator->getTranslator()->get($message);
})->all();

$this->messages = array_merge($this->messages, $messages);
Expand Down

0 comments on commit 45262e6

Please sign in to comment.