1 | <?php |
||
2 | |||
3 | namespace Milwad\LaravelValidate\Rules; |
||
4 | |||
5 | use Illuminate\Contracts\Validation\Rule; |
||
6 | |||
7 | class ValidDuplicate implements Rule |
||
8 | { |
||
9 | /** |
||
10 | * Check duplicate value. |
||
11 | */ |
||
12 | public function passes($attribute, $value): bool |
||
13 | { |
||
14 | $value = str_split($value); |
||
15 | |||
16 | return collect($value)->duplicates()->isEmpty(); |
||
0 ignored issues
–
show
Bug
introduced
by
![]() |
|||
17 | } |
||
18 | |||
19 | /** |
||
20 | * Get the validation error message. |
||
21 | */ |
||
22 | public function message(): string |
||
23 | { |
||
24 | return __('validate.duplicate'); |
||
25 | } |
||
26 | } |
||
27 |