mercredi 24 janvier 2018

Access to another requested input in custom rule class - Laravel

I need to access $request->important in passes method. I need it to validate name based on this value

class TestCustom implements Rule
{
    public function passes($attribute, $value)
    {
        // 
    }

    public function message()
    {
        return 'some txt';
    }
}

Used like this:

use App\Rules\TestCustom;

$request->validate([
    'name' => ['required', new TestCustom],
    'important' => ['required', 'string'],
]);



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire