2021-10-10 18:05:51 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace App\Rules;
|
|
|
|
|
2022-11-27 15:29:29 +00:00
|
|
|
use App\Values\SmartPlaylistRuleGroupCollection;
|
2021-10-10 18:05:51 +00:00
|
|
|
use Illuminate\Contracts\Validation\Rule;
|
2022-11-27 15:29:29 +00:00
|
|
|
use Illuminate\Support\Arr;
|
2021-10-10 18:05:51 +00:00
|
|
|
|
|
|
|
class ValidSmartPlaylistRulePayload implements Rule
|
|
|
|
{
|
|
|
|
public function passes($attribute, $value): bool
|
|
|
|
{
|
2022-11-27 15:29:29 +00:00
|
|
|
return (bool) attempt(static fn () => SmartPlaylistRuleGroupCollection::create(Arr::wrap($value)));
|
2021-10-10 18:05:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public function message(): string
|
|
|
|
{
|
|
|
|
return 'Invalid smart playlist rules';
|
|
|
|
}
|
|
|
|
}
|