mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-07-09 03:14:30 -04:00
Add validation rule for subscription steps
This commit is contained in:
parent
b12fd9a1de
commit
45f3846feb
26
app/Rules/Subscriptions/Steps.php
Normal file
26
app/Rules/Subscriptions/Steps.php
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
<?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]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user