Laravel array validation unique values

Laravel now have ability to check if validation array have only unique values.

It’s very helpful if you want to ensure that user enters only unique values.

In this example we ensure that user create tasks with different titles.

        $validator = Validator::make($request->all(), [
            'task.*.title' => 'required|distinct',
            'task.*.body' => 'required',

        if ($validator->fails()) {
            return redirect('task/create')

More at documentation:
Laravel Validation Distinct values

Share on FacebookShare on RedditShare on Google+Tweet about this on TwitterShare on LinkedIn
don't waste your time using copy/paste, just use share buttons above
Laravel array validation unique values
  • Pingback: Cıvata()

  • hshhhhh

    Where are new posts, man?

    • Justas Maziliauskas

      Hey, working on new ideas. Hope to give you new content very very soon! Just subscribe 😉

      • hshhhhh

        I did because really enjoyed your blog 😉