L5.2 Form request with comma separated string input

Posted 1 month ago by cac

I need to validate a comma separated string. My rules are working as long as I work with array on the request but I've been required to use comma separated string. I heard about some method called prepareForValidation() but it seems to be not available on L5.2.

here are my validation rules:

 public function rules()
        return [
            'array1.*' => 'required|numeric|exists:table1,id',
            'array2.*' => 'required|string|exists:table2,column',

How can I convert my comma separated string before the validation occurs?

Please sign in or create an account to participate in this conversation.