Skip to content

Commit ab30b5d

Browse files
authored
Merge pull request #38 from kuhdmitry/master
add validation for multiple files
2 parents 119e056 + a3257f2 commit ab30b5d

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

src/Form/Element/File.php

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,4 +36,29 @@ public function view()
3636
]);
3737
}
3838

39+
public function validate($keys)
40+
{
41+
if (!$this->isMultiple)
42+
{
43+
return parent::validate($keys);
44+
}
45+
46+
$values = request($keys);
47+
$validator = validator($values, [
48+
$this->name . '.*' => $this->validators
49+
]);
50+
51+
if ($validator->fails())
52+
{
53+
$errors = $validator->errors()
54+
->toArray();
55+
56+
$this->error = array_first($errors);
57+
58+
return false;
59+
}
60+
61+
return true;
62+
}
63+
3964
}

0 commit comments

Comments
 (0)