REDROOM
PHP 8.3.31
Path:
Logout
Edit File
Size: 3.43 KB
Close
/home/getspomw/royalsquad.us/vendor/laravel/framework/src/Illuminate/Validation/Rules/Enum.php
Text
Base64
<?php namespace Illuminate\Validation\Rules; use Illuminate\Contracts\Support\Arrayable; use Illuminate\Contracts\Validation\Rule; use Illuminate\Contracts\Validation\ValidatorAwareRule; use Illuminate\Support\Arr; use Illuminate\Support\Traits\Conditionable; use TypeError; class Enum implements Rule, ValidatorAwareRule { use Conditionable; /** * The type of the enum. * * @var class-string */ protected $type; /** * The current validator instance. * * @var \Illuminate\Validation\Validator */ protected $validator; /** * The cases that should be considered valid. * * @var array */ protected $only = []; /** * The cases that should be considered invalid. * * @var array */ protected $except = []; /** * Create a new rule instance. * * @param class-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 ($value instanceof $this->type) { return $this->isDesirable($value); } if (is_null($value) || ! enum_exists($this->type) || ! method_exists($this->type, 'tryFrom')) { return false; } try { $value = $this->type::tryFrom($value); return ! is_null($value) && $this->isDesirable($value); } catch (TypeError) { return false; } } /** * Specify the cases that should be considered valid. * * @param \UnitEnum[]|\UnitEnum|\Illuminate\Contracts\Support\Arrayable<array-key, \UnitEnum> $values * @return $this */ public function only($values) { $this->only = $values instanceof Arrayable ? $values->toArray() : Arr::wrap($values); return $this; } /** * Specify the cases that should be considered invalid. * * @param \UnitEnum[]|\UnitEnum|\Illuminate\Contracts\Support\Arrayable<array-key, \UnitEnum> $values * @return $this */ public function except($values) { $this->except = $values instanceof Arrayable ? $values->toArray() : Arr::wrap($values); return $this; } /** * Determine if the given case is a valid case based on the only / except values. * * @param mixed $value * @return bool */ protected function isDesirable($value) { return match (true) { ! empty($this->only) => in_array(needle: $value, haystack: $this->only, strict: true), ! empty($this->except) => ! in_array(needle: $value, haystack: $this->except, strict: true), default => true, }; } /** * Get the validation error message. * * @return array */ public function message() { $message = $this->validator->getTranslator()->get('validation.enum'); return $message === 'validation.enum' ? ['The selected :attribute is invalid.'] : $message; } /** * Set the current validator. * * @param \Illuminate\Validation\Validator $validator * @return $this */ public function setValidator($validator) { $this->validator = $validator; return $this; } }
Save
Close
Exit & Reset
Text mode: syntax highlighting auto-detects file type.
Directory Contents
Dirs: 0 × Files: 17
Delete Selected
Select All
Select None
Sort:
Name
Size
Modified
Enable drag-to-move
Name
Size
Perms
Modified
Actions
ArrayRule.php
986 B
lrw-rw-rw-
2025-09-17 06:52:58
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
Can.php
1.80 KB
lrw-rw-rw-
2025-09-17 06:52:58
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
DatabaseRule.php
5.37 KB
lrw-rw-rw-
2025-09-17 06:52:58
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
Date.php
3.24 KB
lrw-rw-rw-
2025-09-17 06:52:58
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
Dimensions.php
3.17 KB
lrw-rw-rw-
2025-09-17 06:52:58
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
Email.php
6.59 KB
lrw-rw-rw-
2025-09-17 06:52:58
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
Enum.php
3.43 KB
lrw-rw-rw-
2025-09-17 06:52:58
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
ExcludeIf.php
1.06 KB
lrw-rw-rw-
2025-09-17 06:52:58
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
Exists.php
476 B
lrw-rw-rw-
2025-09-17 06:52:58
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
File.php
9.25 KB
lrw-rw-rw-
2025-09-17 06:52:58
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
ImageFile.php
508 B
lrw-rw-rw-
2025-09-17 06:52:58
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
In.php
1.20 KB
lrw-rw-rw-
2025-09-17 06:52:58
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
NotIn.php
1.14 KB
lrw-rw-rw-
2025-09-17 06:52:58
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
Password.php
8.59 KB
lrw-rw-rw-
2025-09-17 06:52:58
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
ProhibitedIf.php
1.07 KB
lrw-rw-rw-
2025-09-17 06:52:58
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
RequiredIf.php
999 B
lrw-rw-rw-
2025-09-17 06:52:58
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
Unique.php
1.62 KB
lrw-rw-rw-
2025-09-17 06:52:58
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
Zip Selected
If ZipArchive is unavailable, a
.tar
will be created (no compression).