php-tenant/Rules/ResourceStatusRule.php
Snider d0ad2737cb refactor: rename namespace from Core\Mod\Tenant to Core\Tenant
Simplifies the namespace hierarchy by removing the intermediate Mod
segment. Updates all 118 files including models, services, controllers,
middleware, tests, and composer.json autoload configuration.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-27 16:30:46 +00:00

39 lines
1.1 KiB
PHP

<?php
declare(strict_types=1);
namespace Core\Tenant\Rules;
use Closure;
use Core\Mod\Social\Enums\ResourceStatus;
use Illuminate\Contracts\Validation\ValidationRule;
/**
* Validates that a value is a valid ResourceStatus enum value.
*
* This ensures that status fields only accept ENABLED (1) or DISABLED (0)
* as defined in the ResourceStatus enum.
*
* Used for validating status changes on social resources such as:
* - Bio links
* - Bio link blocks
* - Social accounts
* - Social templates
* - Webhooks
*/
class ResourceStatusRule implements ValidationRule
{
/**
* Run the validation rule.
*
* @param string $attribute The attribute being validated
* @param mixed $value The value being validated
* @param Closure $fail Closure to call if validation fails
*/
public function validate(string $attribute, mixed $value, Closure $fail): void
{
if (! in_array($value, [ResourceStatus::DISABLED->value, ResourceStatus::ENABLED->value], true)) {
$fail('The :attribute must be either enabled or disabled.');
}
}
}