mirror of
https://github.com/koel/koel
synced 2024-11-24 21:23:06 +00:00
27 lines
657 B
PHP
27 lines
657 B
PHP
<?php
|
|
|
|
namespace App\Rules;
|
|
|
|
use App\Values\SmartPlaylistRule;
|
|
use Illuminate\Contracts\Validation\Rule;
|
|
|
|
class ValidSmartPlaylistRulePayload implements Rule
|
|
{
|
|
public function passes($attribute, $value): bool
|
|
{
|
|
return attempt(static function () use ($value) {
|
|
foreach ((array) $value as $ruleGroupConfig) {
|
|
foreach ($ruleGroupConfig['rules'] as $rule) {
|
|
SmartPlaylistRule::assertConfig($rule, false);
|
|
}
|
|
}
|
|
|
|
return true;
|
|
}, false) ?? false;
|
|
}
|
|
|
|
public function message(): string
|
|
{
|
|
return 'Invalid smart playlist rules';
|
|
}
|
|
}
|