2024-01-23 22:50:50 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace App\Rules;
|
|
|
|
|
|
|
|
use App\Values\UserPreferences;
|
2024-05-19 05:49:42 +00:00
|
|
|
use Closure;
|
|
|
|
use Illuminate\Contracts\Validation\ValidationRule;
|
2024-01-23 22:50:50 +00:00
|
|
|
|
2024-05-19 05:49:42 +00:00
|
|
|
class CustomizableUserPreference implements ValidationRule
|
2024-01-23 22:50:50 +00:00
|
|
|
{
|
2024-05-19 05:49:42 +00:00
|
|
|
public function validate(string $attribute, mixed $value, Closure $fail): void
|
2024-01-23 22:50:50 +00:00
|
|
|
{
|
2024-05-19 05:49:42 +00:00
|
|
|
if (!UserPreferences::customizable($value)) {
|
|
|
|
$fail('Invalid or uncustomizable user preference key.');
|
|
|
|
}
|
2024-01-23 22:50:50 +00:00
|
|
|
}
|
|
|
|
}
|