changing attribute value on validation class in laravel

  laravel, laravel-validation

How can we change attribute values on validation classes in laravel ?
consider this code:

class Twice implements Rule
{ 
  public function passes($attribute, $value)
    {
        $value = $value * 2;
        return $value > 20;
    }
}

and now we receive value multiply by 2 in score attribute:

$rules = [
'score' => [new Twice]
]

if we can’t, what is your suggestion ?

Source: Laravel

Leave a Reply