Support the ongoing development of Laravel.io →
Requests Views Validation

I am creating Validation service witch throws ValidationException if error ocured. That works fine, like it should, but got to the point where i need different exception outcomes depending on wather it responds to an ajax request or not.

Now i am checking in exception handler weather it is ajax request or not and return different responses.

I am creating service for validation to separate concerns, so validation exception shouldn't care about how data should be returned. So my current solution does not fallow separation of concerns pattern.

I was thinking of creating some Response service witch will be called from exception handler and will decade what format to return data. It could then be used for all sorts of different response/exception handling?

So i was wonderig what woulbe the best way for this. Mybe you have some ideas.

Thanks.

Last updated 2 years ago.
0

Sign in to participate in this thread!

Eventy

Your banner here too?

revati revati Joined 31 Jan 2014

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2025 Laravel.io - All rights reserved.