check if currency code is string

This commit is contained in:
denisdulici
2018-09-06 01:45:33 +03:00
parent 2e5f0fcb27
commit 104451a4ba

View File

@@ -19,10 +19,14 @@ class ValidationServiceProvider extends ServiceProvider
Validator::extend('currency', function ($attribute, $value, $parameters, $validator) use(&$currency_code) {
$status = false;
if (!is_string($value) || (strlen($value) != 3)) {
return $status;
}
$currencies = Currency::enabled()->pluck('name', 'code')->toArray();
$currencies = Currency::enabled()->pluck('code')->toArray();
if (array_key_exists($value, $currencies)) {
if (in_array($value, $currencies)) {
$status = true;
}