👩💻 Join our community of thousands of amazing developers!
Sometimes, you might end up in a situation where you would want to add certain validation rules for fields. Now, Laravel already has a somtimes method in the Illuminate\Support\Facades\Validator facade that can be used to only add certain validation rules if the Closure passed to it returns true. But that’s quite verbose if you ask me. There was a need for something simple and that’s where a when method is added to the Illuminate\Validation\Rule class. The Rule::when() method As I said, Laravel ...