Validation, I got confused that these are not done at one place. #783
Replies: 2 comments
-
I believe we have this behavior for the following reasons: 1.Multiple Validation Locations: a) Entity Configurations (Infrastructure layer): These are primarily for database schema definition, not application-level validation. They define things like column types, sizes, and nullability. b) Entity-level checks: These enforce the basic integrity of the entity itself, ensuring it's always in a valid state. c) Application-level validations: These would typically be in the Application layer and handle more complex business rules. 2.Clean Architecture and Validation: |
Beta Was this translation helpful? Give feedback.
-
I agree with @ParsaMehdipour . I'll add that it's important to understand the difference between validation and guarding against invariants (such as in the domain model). See here for more on that: |
Beta Was this translation helpful? Give feedback.
-
What a great effort @ardalis sir, i have to setup new project and i was looking for some point to get started.
I go deep in to this repo and got to know that some how the validations are add at multiple places, Entities configurations in infrastructure layer here Rules for columns are added. And then at Entity level some checks (At least the null checks) are added.
I got confused with the approach. This is something that i am looking in different clean architecture repose.
I know for Database table columns configurations we don't say validation but still these are rules and if there could be some mechanism except data annotations to manage at one place.
Beta Was this translation helpful? Give feedback.
All reactions