Skip to content

Commit 8b69c6f

Browse files
author
riccardodallavia
committed
FIX custom rules validation
1 parent b079430 commit 8b69c6f

File tree

2 files changed

+6
-0
lines changed

2 files changed

+6
-0
lines changed

src/Rules/ExistsEncrypted.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,15 @@
55
use HFarm\Encryptable\Encryption;
66
use Illuminate\Contracts\Validation\Rule;
77
use Illuminate\Support\Facades\Validator;
8+
use Illuminate\Support\Str;
89
use Illuminate\Validation\Rules\Exists;
910

1011
class ExistsEncrypted extends Exists implements Rule
1112
{
1213
public function passes($attribute, $value): bool
1314
{
15+
$attribute = Str::before($attribute, '.');
16+
1417
return ! Validator::make([
1518
$attribute => Encryption::php()->encrypt($value),
1619
], [

src/Rules/UniqueEncrypted.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,15 @@
55
use HFarm\Encryptable\Encryption;
66
use Illuminate\Contracts\Validation\Rule;
77
use Illuminate\Support\Facades\Validator;
8+
use Illuminate\Support\Str;
89
use Illuminate\Validation\Rules\Unique;
910

1011
class UniqueEncrypted extends Unique implements Rule
1112
{
1213
public function passes($attribute, $value): bool
1314
{
15+
$attribute = Str::before($attribute, '.');
16+
1417
return ! Validator::make([
1518
$attribute => Encryption::php()->encrypt($value),
1619
], [

0 commit comments

Comments
 (0)