1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-11-15 07:33:04 +01:00
invoiceninja/app/Rules/Subscriptions/Steps.php
2024-03-01 13:43:00 +01:00

27 lines
654 B
PHP

<?php
namespace App\Rules\Subscriptions;
use App\Services\Subscription\StepService;
use Closure;
use App\Livewire\BillingPortal\Purchase;
use Illuminate\Contracts\Validation\ValidationRule;
class Steps implements ValidationRule
{
/**
* Run the validation rule.
*
* @param \Closure(string): \Illuminate\Translation\PotentiallyTranslatedString $fail
*/
public function validate(string $attribute, mixed $value, Closure $fail): void
{
$steps = StepService::mapToClassNames($value);
$errors = StepService::check($steps);
if (count($errors) > 0) {
$fail($errors[0]);
}
}
}