formers/former

Custom Rule classes not working

Opened this issue · 1 comments

Hi!

This seems like dumb question, but are custom rule classes supported by Former?

I'm getting the following error when I try to pass my form request rules to Former:

strpos() expects parameter 1 to be string, object given

This happens in the Former.php file on line 315:

foreach ($expFieldRules as $rule) {
    $parameters = null;
 
    if (($colon = strpos($rule, ':')) !== false) {   // <-------------------
         $rulename = substr($rule, 0, $colon);
...
}

To me it seems like there's a check on rule objects missing.

Thanks!

It is correct they currently give an error when used, they are indeed not supported by Former.

For now we will prevent errors (after #592 is merged) when passing Rule objects and in the future it's possible Former will support Rule classes.