File "DataRules.php"
Full Path: /var/www/html/back/vendor/spatie/laravel-data/src/Support/Validation/DataRules.php
File size: 961 bytes
MIME-type: text/x-php
Charset: utf-8
<?php
namespace Spatie\LaravelData\Support\Validation;
use Illuminate\Validation\NestedRules;
class DataRules
{
/**
* @param array<array|\Spatie\LaravelData\Support\Validation\PropertyRules|NestedRules> $rules
*/
public function __construct(
public array $rules = [],
) {
}
public static function create(): self
{
return new self();
}
public function add(
ValidationPath $path,
array $rules
): self {
$this->rules[$path->get()] = $rules;
return $this;
}
public function merge(
ValidationPath $path,
array $rules
): self {
$this->rules[$path->get()] = array_merge($this->rules[$path->get()] ?? [], $rules);
return $this;
}
public function addCollection(
ValidationPath $path,
NestedRules $rules
): self {
$this->rules["{$path->get()}.*"] = $rules;
return $this;
}
}