Support the ongoing development of Laravel.io →
posted 10 years ago
Validation
Last updated 1 year ago.
0

Your class will need a validate method as specified by @validate.

 public function validate($attribute, $value, $parameters)
    {
        return $value == 'foo';
    }
Last updated 1 year ago.
0

I did have a validate method. But I did not have the same method signature. Thank you!

Last updated 1 year ago.
0

For those looking to access data from the whole model which is being validated, inside your validation method (shown above), you can access a forth parameter passed to your method ($validationModel):

public function validate($attribute, $value, $parameters, $validationModel)
{
        var_dump($validationModel->getData());
        // Logic here
}
0

Sign in to participate in this thread!

Eventy

Your banner here too?

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2024 Laravel.io - All rights reserved.