OneWayFailureUseCase<TYPE extends Failure, UsecaseParams extends Params> class
abstract
A specialized Usecase designed to produce an optional Failure result, but no successful domain Entity.
It implements the Option functional pattern where:
- None: Represents Success (no failure occurred).
- Some(Failure): Represents a Problem found during the check.
✅ Benefits:
- Focused Purpose: Ideal for standalone validation logic, permission checks, or "guard clauses" that don't need to return data.
- UI Integration: Very easy to use in form validation where you only care if there is an error message to display.
- Lightweight: Avoids the overhead of defining a "Success" entity when the only goal is to verify a condition.
❌ Downsides:
- Inverted Intuition: Confusing that
Nonemeans "everything is okay." - Limited Flow: Cannot pass data forward. If you need to validate and then
use the validated data, a standard
UseCaseorUseCaseHandleris better.
Best for: Validation or verification Usecase (e.g., "Check if Username is Taken" or "Verify Premium Subscription Status").
Type Parameter:
TYPE: The specific type of Failure returned if the condition fails.
Constructors
- OneWayFailureUseCase()
-
const
Properties
- hashCode → int
-
The hash code for this object.
no setterinherited
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
call(
UsecaseParams params) → Future< Option< TYPE> > -
Executes the logic and returns an Option containing the Failure
if the condition fails, or None if the check passes (success).
override
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited