$choices the declared select option values */ public function __construct(private string $field, private array $choices = []) {} /** * Run the validation rule. * * @param Closure(string, ?string=): PotentiallyTranslatedString $fail */ public function validate(string $attribute, mixed $value, Closure $fail): void { try { ExtensionSettingValueGuard::assertValue($value); $valid = ExtensionSettingValueGuard::fitsField($this->field, $value, $this->choices); } catch (UnexpectedValueException) { $valid = false; } if (! $valid) { $fail(match ($this->field) { 'number' => 'The :attribute must be a number.', 'toggle' => 'The :attribute must be true or false.', 'select' => 'The selected :attribute is not one of the options.', default => 'The :attribute must be text.', }); } } }