Validating Business Rules
Explore how to identify and implement business rule validations within a Hexagonal Architecture web application. Understand the difference between input validation and business rule validation based on domain state access. Learn best practices for placing business rules inside domain entities or use case code to ensure maintainability and clarity in your software design.
We'll cover the following...
Validation
While validating input is not part of the use case logic, validating business rules definitely is. Business rules are the core of the application and should be handled with appropriate care. But when are we dealing with input validation and when with a business rule?
A very pragmatic distinction between the two is that validating a business rule requires access to the current state of the domain model while validating input does not. Input validation can be implemented declaratively, like we did with the @NotNull annotations previously, while a business rule needs ...