0

I want to ask about custom validation. I make validation for counting the word

Validator::extend('word_count', function($attribute, $value, $parameters, $validator) {

       return str_word_count($value) >= $parameters;

});

How can i give name to parameter so that i can use the parameter value in error message?

1
  • What you want exactly please specify. You want the error message with value entered by user. right? Commented Nov 2, 2016 at 5:13

1 Answer 1

1

Based on your question, i will understand you care about the validation message.

If you are looking for validation message mean, you can use custom message like,

If you are using the request file means, there we can use

messages(){
   return [
    'word_count' => '....', //some message will be here,
   ];
}

If you are using controller means, then use like

return response()->json('...', 422);

or

here also you can use that above messages function.

I hope, it will help you.If any thing ask here.

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.