1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-11-18 09:04:35 +01:00
invoiceninja/app/Http/ValidationRules/ValidSettingsRule.php

51 lines
1.0 KiB
PHP
Raw Normal View History

2019-10-10 03:01:38 +02:00
<?php
/**
* Invoice Ninja (https://invoiceninja.com).
2019-10-10 03:01:38 +02:00
*
* @link https://github.com/invoiceninja/invoiceninja source repository
*
* @copyright Copyright (c) 2021. Invoice Ninja LLC (https://invoiceninja.com)
2019-10-10 03:01:38 +02:00
*
* @license https://opensource.org/licenses/AAL
*/
namespace App\Http\ValidationRules;
2019-10-10 04:24:19 +02:00
use App\Utils\Traits\SettingsSaver;
2019-10-10 03:01:38 +02:00
use Illuminate\Contracts\Validation\Rule;
/**
* Class ValidSettingsRule.
2019-10-10 03:01:38 +02:00
*/
class ValidSettingsRule implements Rule
{
2019-10-10 04:24:19 +02:00
use SettingsSaver;
2019-10-10 03:01:38 +02:00
/**
* @param string $attribute
* @param mixed $value
* @return bool
*/
public $return_data;
public function passes($attribute, $value)
{
$data = $this->validateSettings($value);
if (is_array($data)) {
2019-10-10 03:01:38 +02:00
$this->return_data = $data;
2019-10-10 03:01:38 +02:00
return false;
} else {
2019-10-10 03:01:38 +02:00
return true;
}
2019-10-10 03:01:38 +02:00
}
/**
* @return string
*/
public function message()
{
return $this->return_data[0].' is not a valid '.$this->return_data[1].' ( '.$this->return_data[2].' )';
2019-10-10 03:01:38 +02:00
}
}