Skip to content

Commit c6710ee

Browse files
committed
reverted #94
1 parent 8433753 commit c6710ee

File tree

1 file changed

+7
-9
lines changed

1 file changed

+7
-9
lines changed

src/Rules/CurrencyRule.php

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,20 +3,18 @@
33
namespace Akaunting\Money\Rules;
44

55
use Akaunting\Money\Currency;
6-
use Closure;
7-
use Illuminate\Contracts\Validation\ValidationRule;
6+
use Illuminate\Contracts\Validation\Rule;
87

9-
class CurrencyRule implements ValidationRule
8+
class CurrencyRule implements Rule
109
{
11-
public function validate(string $attribute, mixed $value, Closure $fail): void
10+
public function passes($attribute, $value): bool
1211
{
13-
if (! $this->passes($value)) {
14-
$fail('money.invalid-currency')->translate();
15-
}
12+
return is_string($value) && key_exists(strtoupper($value), Currency::getCurrencies());
1613
}
1714

18-
protected function passes(mixed $value): bool
15+
public function message()
1916
{
20-
return is_string($value) && array_key_exists(strtoupper($value), Currency::getCurrencies());
17+
/** @var string */
18+
return trans('money.invalid-currency');
2119
}
2220
}

0 commit comments

Comments
 (0)