D
D
D3V1L2018-07-25 01:02:58
Laravel
D3V1L, 2018-07-25 01:02:58

How to add a parameter to request before validation?

Goodnight. I came across this case:

$request->fingerprint = $gpg->getFingerprint($request->public_key);

        $this->validate($data, [
            'login' => 'required|unique:users|max:10',
            'name' => 'required|max:10',
            'public_key' => 'required',
            'fingerprint' => 'required|unique:users'
        ]);

I work with GnuPG and need to check the fingerprint in the database, but to get it, you first need to extract it from the function, ajax is not considered, since there is a complete no js solution, that is, it will not be possible to get it before the request is formed. And with this addition, the validator swears that the fingerprint is an empty field. That is the error 'Fingerprint is required'. I tried to remove required, it sends null to the database, but when outputting via dd request'a, this parameter is available.
How can you act in such a situation?
Thanks in advance.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
J
JhaoDa, 2018-07-25
@D3V1L

$request->merge()
But in general, I recommend discovering such a thing as a form request.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question