moshemo
2 weeks ago

Create Method with Validating Only Some Fields

Posted 2 weeks ago by moshemo

I am referencing this episode: https://laracasts.com/series/laravel-6-from-scratch/episodes/27

Jeffrey notes a way to use the create with the validate method -- like this:

Article::create(request()->validate([
 'title' => 'required',
 'excerpt' => 'required',
 'body' => 'required'
]));

My question is how could I rework this code if I only wanted to validate some of the fields (so, only the title field). How could I do that?

Thanks.

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