Skip to content

Commit 1437e11

Browse files
authored
RulesParser for file fields+
1 parent 8727408 commit 1437e11

File tree

1 file changed

+23
-1
lines changed

1 file changed

+23
-1
lines changed

src/Kris/LaravelFormBuilder/RulesParser.php

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ public function __construct(FormField $field)
4343
public function parse($rules)
4444
{
4545
$attributes = array();
46-
$rules = $rule = $this->getRulesAsArray($rules);
46+
$rules = $this->getRulesAsArray($rules);
4747

4848
foreach ($rules as $rule) {
4949
list($rule, $parameters) = $this->parseRule($rule);
@@ -273,6 +273,10 @@ protected function min($param)
273273
return ['min' => $min];
274274
}
275275

276+
if ($this->isFile()) {
277+
return [];
278+
}
279+
276280
return [
277281
'minlength' => $min,
278282
];
@@ -298,6 +302,10 @@ protected function max($param)
298302
return ['max' => $max];
299303
}
300304

305+
if ($this->isFile()) {
306+
return [];
307+
}
308+
301309
return ['maxlength' => $max];
302310
}
303311

@@ -324,6 +332,10 @@ protected function between($param)
324332
];
325333
}
326334

335+
if ($this->isFile()) {
336+
return [];
337+
}
338+
327339
return [
328340
'minlength' => $min,
329341
'maxlength' => $max,
@@ -504,6 +516,16 @@ protected function isNumeric()
504516
return $this->isType(['number', 'range']);
505517
}
506518

519+
/**
520+
* Check if the field is a file.
521+
*
522+
* @return bool
523+
*/
524+
protected function isFile()
525+
{
526+
return $this->isType(['file']);
527+
}
528+
507529
/**
508530
* Format a date to the correct format, based on the current field.
509531
*

0 commit comments

Comments
 (0)