This commit is contained in:
2026-05-01 23:40:14 +08:00
commit b8f599a617
3867 changed files with 478663 additions and 0 deletions
+51
View File
@@ -0,0 +1,51 @@
<?php
namespace Illuminate\Validation\Rules;
use Illuminate\Contracts\Support\Arrayable;
use Stringable;
use function Illuminate\Support\enum_value;
class ArrayRule implements Stringable
{
/**
* The accepted keys.
*
* @var array
*/
protected $keys;
/**
* Create a new array rule instance.
*
* @param \Illuminate\Contracts\Support\Arrayable|array|null $keys
*/
public function __construct($keys = null)
{
if ($keys instanceof Arrayable) {
$keys = $keys->toArray();
}
$this->keys = is_array($keys) ? $keys : func_get_args();
}
/**
* Convert the rule to a validation string.
*
* @return string
*/
public function __toString()
{
if (empty($this->keys)) {
return 'array';
}
$keys = array_map(
static fn ($key) => enum_value($key),
$this->keys,
);
return 'array:'.implode(',', $keys);
}
}