CaptainCodeman / clean-go

Clean Architecture Example in Go
279 stars 26 forks source link

which layer we should validate request? #3

Closed aliuygur closed 7 years ago

aliuygur commented 7 years ago

hello,

I haven't seen a request validation so which layer we should add validation logic?

thank you

CaptainCodeman commented 7 years ago

I think this would go into the engine, see: https://github.com/CaptainCodeman/clean-go/blob/master/engine/greeter_add.go

By applying it here, it would be used by any UI and doesn't need to be repeated for each storage provider.

The UI may have some checks that a request is valid based on their own interface - a web service might check that a request is valid JSON for instance as part of what it does. The storage might also have some checks to protect the data consistency (from someone using DB admin tools for instance) but ultimately, the domain logic for the app should be applied in the engine as there may be things that only it can decide (with the help of the domain).

Also look at the read-me which describes what goes in the various parts, particularly: https://github.com/CaptainCodeman/clean-go#domain https://github.com/CaptainCodeman/clean-go#engine--use-cases

aliuygur commented 7 years ago

I think so. Thank you so much.