Skip to content

Commit

Permalink
reverted #94
Browse files Browse the repository at this point in the history
  • Loading branch information
denisdulici committed Mar 19, 2024
1 parent 8433753 commit c6710ee
Showing 1 changed file with 7 additions and 9 deletions.
16 changes: 7 additions & 9 deletions src/Rules/CurrencyRule.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,18 @@
namespace Akaunting\Money\Rules;

use Akaunting\Money\Currency;
use Closure;
use Illuminate\Contracts\Validation\ValidationRule;
use Illuminate\Contracts\Validation\Rule;

class CurrencyRule implements ValidationRule
class CurrencyRule implements Rule
{
public function validate(string $attribute, mixed $value, Closure $fail): void
public function passes($attribute, $value): bool
{
if (! $this->passes($value)) {
$fail('money.invalid-currency')->translate();
}
return is_string($value) && key_exists(strtoupper($value), Currency::getCurrencies());
}

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

0 comments on commit c6710ee

Please sign in to comment.