mirror of
https://github.com/koel/koel
synced 2024-12-24 11:33:05 +00:00
32 lines
701 B
PHP
32 lines
701 B
PHP
|
<?php
|
||
|
|
||
|
namespace App\Rules;
|
||
|
|
||
|
use App\Values\SmartPlaylistRule;
|
||
|
use Illuminate\Contracts\Validation\Rule;
|
||
|
use Throwable;
|
||
|
|
||
|
class ValidSmartPlaylistRulePayload implements Rule
|
||
|
{
|
||
|
/** @param array $value */
|
||
|
public function passes($attribute, $value): bool
|
||
|
{
|
||
|
try {
|
||
|
foreach ((array) $value as $ruleGroupConfig) {
|
||
|
foreach ($ruleGroupConfig['rules'] as $rule) {
|
||
|
SmartPlaylistRule::assertConfig($rule, false);
|
||
|
}
|
||
|
}
|
||
|
|
||
|
return true;
|
||
|
} catch (Throwable $e) {
|
||
|
return false;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
public function message(): string
|
||
|
{
|
||
|
return 'Invalid smart playlist rules';
|
||
|
}
|
||
|
}
|