File tree Expand file tree Collapse file tree 1 file changed +7
-9
lines changed Expand file tree Collapse file tree 1 file changed +7
-9
lines changed Original file line number Diff line number Diff line change 3
3
namespace Akaunting \Money \Rules ;
4
4
5
5
use Akaunting \Money \Currency ;
6
- use Closure ;
7
- use Illuminate \Contracts \Validation \ValidationRule ;
6
+ use Illuminate \Contracts \Validation \Rule ;
8
7
9
- class CurrencyRule implements ValidationRule
8
+ class CurrencyRule implements Rule
10
9
{
11
- public function validate ( string $ attribute , mixed $ value, Closure $ fail ): void
10
+ public function passes ( $ attribute , $ value ): bool
12
11
{
13
- if (! $ this ->passes ($ value )) {
14
- $ fail ('money.invalid-currency ' )->translate ();
15
- }
12
+ return is_string ($ value ) && key_exists (strtoupper ($ value ), Currency::getCurrencies ());
16
13
}
17
14
18
- protected function passes ( mixed $ value ): bool
15
+ public function message ()
19
16
{
20
- return is_string ($ value ) && array_key_exists (strtoupper ($ value ), Currency::getCurrencies ());
17
+ /** @var string */
18
+ return trans ('money.invalid-currency ' );
21
19
}
22
20
}
You can’t perform that action at this time.
0 commit comments