check if currency code is string
This commit is contained in:
@@ -20,9 +20,13 @@ class ValidationServiceProvider extends ServiceProvider
|
|||||||
Validator::extend('currency', function ($attribute, $value, $parameters, $validator) use(&$currency_code) {
|
Validator::extend('currency', function ($attribute, $value, $parameters, $validator) use(&$currency_code) {
|
||||||
$status = false;
|
$status = false;
|
||||||
|
|
||||||
$currencies = Currency::enabled()->pluck('name', 'code')->toArray();
|
if (!is_string($value) || (strlen($value) != 3)) {
|
||||||
|
return $status;
|
||||||
|
}
|
||||||
|
|
||||||
if (array_key_exists($value, $currencies)) {
|
$currencies = Currency::enabled()->pluck('code')->toArray();
|
||||||
|
|
||||||
|
if (in_array($value, $currencies)) {
|
||||||
$status = true;
|
$status = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user