![]() Server : Apache System : Linux server2.corals.io 4.18.0-348.2.1.el8_5.x86_64 #1 SMP Mon Nov 15 09:17:08 EST 2021 x86_64 User : corals ( 1002) PHP Version : 7.4.33 Disable Function : exec,passthru,shell_exec,system Directory : /home/corals/syn.corals.io/vendor/laravel/framework/src/Illuminate/Validation/Rules/ |
<?php namespace Illuminate\Validation\Rules; use Illuminate\Contracts\Validation\Rule; class Enum implements Rule { /** * The type of the enum. * * @var string */ protected $type; /** * Create a new rule instance. * * @param string $type * @return void */ public function __construct($type) { $this->type = $type; } /** * Determine if the validation rule passes. * * @param string $attribute * @param mixed $value * @return bool */ public function passes($attribute, $value) { if (is_null($value) || ! function_exists('enum_exists') || ! enum_exists($this->type)) { return false; } return ! is_null($this->type::tryFrom($value)); } /** * Get the validation error message. * * @return array */ public function message() { return [ 'The selected :attribute is invalid.', ]; } }