feat(validator): add file upload validation rules

This commit is contained in:
kj
2026-09-03 18:07:54 -03:00
parent 31728af351
commit 44cbe6bbdc
2 changed files with 551 additions and 12 deletions

View File

@@ -76,10 +76,17 @@ class Request extends Neuron
default => $this->get
};
// Merge uploaded files ($_FILES) into the body data set so the file rules
// (file/image/mimes and the routed min/max/required...) can validate
// uploads through a Request. $this->post is left untouched.
$body = empty($_FILES)
? $actual
: new Neuron(array_merge(get_object_vars($actual), $_FILES));
if (
Validator::validateList(static::paramRules(), $this->params) &&
Validator::validateList(static::getRules(), $this->get) &&
Validator::validateList(static::rules(), $actual)
Validator::validateList(static::rules(), $body)
) {
return true;
}