0

I'm creating a custom validation customVal on the input field username. I'm sending other input as a parameter, but the value of the parameter is being received as null.

In my controller I have:

$this->validate(request(),[
  'username' => 'customVal: firstname',
]);

And on app\Providers\AppServiceProviders I'm dumping the first parameter as a test:

public function boot()
{
  \Validator::extend('customVal', function ($attribute, $value, $parameters, $validator)
  {
    dd( Request::get($parameters[0]) ."-". request($parameters[0]) ."-". Input::get($parameters[0]) ."-". $parameters[0] );
    return true;
  });
}

which shows

"--- firstname"

...the value is null, however I can get it's name (firstname). And just to make sure, when I dump this on the controller:

dd( $request->get('firstname') ."-". request('firstname') ."-". Input::get('firstname') ."-". 'firstname' );

I get:

"myname-myname-myname-firstname"

So that's basically it, I can't work on the custom validation because I can't get any values.

And I'm guessing the same happens when I try to use the require_without_all validation. Because it doesn't recognize it's parameters (what I write on the fields)

3
  • 1
    Remove the space in between : and firstname in your validation array. Commented May 1, 2017 at 4:02
  • That solved! thanks a lot, I can't believe all the hours I wasted on this. Can I accept your comment as the right answer? Commented May 1, 2017 at 8:06
  • I made it an answer so you can accept. Commented May 1, 2017 at 17:33

1 Answer 1

1

Remove the space in between : and firstname in your validation array.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.