AbstractAbstractisChecks if the candidate satisfies this specification.
The object to check
true if the candidate satisfies this specification
Creates a new specification that is satisfied only if both this specification AND the other specification are satisfied.
The other specification to combine with
A new specification representing the AND operation
Creates a new specification that is satisfied if either this specification OR the other specification is satisfied.
The other specification to combine with
A new specification representing the OR operation
Creates a new specification that is satisfied only if this specification is NOT satisfied.
A new specification representing the NOT operation
Checks if the candidate satisfies this specification and returns a detailed result.
This method can be overridden to provide more detailed error messages when a specification is not satisfied.
The object to check
A result object with success status and optional error message
Specification Pattern for encapsulating business rules and validation logic.
Specifications allow you to compose complex business rules using logical operators (AND, OR, NOT) while keeping each rule independently testable and reusable.
Example