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