-
Notifications
You must be signed in to change notification settings - Fork 0
Motivation
Han edited this page Sep 26, 2021
·
2 revisions
The reasons for creating this library are:
- A simple structure for creating validations that throw an exception.
- An easy-to-use DSL that guides the user in how to use the library.
- Avoiding combing lots of validation logic in one guard clause.
- Avoid using reflection style annotations for this, less magic
- Easy to debug
- Easy to read code when implementing multiple validation rules on one input, instead of lots of complex logic in an 'if' statement.
- Use of Java 8+ predicates to create validation rules. This allows rules to be combined using a predicate interface using logical operands (and, or and not).
- Several ways of return exceptions, either throw an exception on first validation failed, or throw all exceptions under a wrapper exception when multiple validation rules fail (notification patterns).
- Can build a set of rules (predicates) and share within the codebase, or as an accompanying library to Valid8or.
This is not for simple validations, where a simple guard clause (if statement throwing an exception) would be needed due to its simplicity.