feat(validator): add file upload validation rules
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user