Laravel validation require at least one array without empty field

Viewed 156

Request inputs are:

['posts' =>
    [
        'language_id' => ...,
        'title' => ...,
        'content' => ...
    ],
    .
    .
    .
]

So i need at least one not empty post (or at least one post without empty title). For now i decided to make custom validation rule that will be used like: 'posts' => 'at_least_one:title' that will check if there is at least one post without empty title.

Does anybody know some way to make this possible without making of custom validation rule?

1 Answers
foreach($posts as $post){
    $title = isset($post['title']) ? $post['title'] : '';
    if($title ==''){
     /** */
    }else{
      /**   */`
    }`
   }
Related