Valid<T extends Object?> class
final
Represents a successful validation with the validated value.
A Valid contains the original value that passed all validation checks. You can continue chaining additional validations on a Valid result using the ValidatedOps.check extension method. The value is preserved through the entire validation chain.
Construct Valid results using Validated.valid factory method or the check function/ValidatedOps.check extension.
Example:
// Create a valid result
final result = Validated.valid('valid@email.com');
// Continue chaining validations
final validated = result
.check((email) => email.contains('@'), error: 'Invalid format')
.check((email) => !email.startsWith('.'), error: 'Cannot start with period');
- Inheritance
- Available extensions
- Annotations
-
- @experimental
- @immutable
Properties
- hashCode → int
-
The hash code for this object.
no setteroverride
- isValid → bool
-
Returns true if this is a Valid result, false if Invalid.
no setterinherited
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- value → T
-
The value that passed all validation checks.
final
Methods
-
and(
Validated< T> other) → Validated<T> -
Combines two validation results, merging their errors.
inherited
-
asResult(
) → Result< T, Set< String> > -
Converts this validation result to a Result type.
inherited
-
check(
bool rule(T), {required String error}) → Validated< T> -
Available on Validated<
Applies an additional validation rule to this result.T> , provided by the ValidatedOps extension -
getErrors(
) → Set< String> ? -
Gets errors if Invalid, null if Valid.
inherited
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toString(
) → String -
A string representation of this object.
inherited
-
unwrapOrNull(
) → T? -
Extracts the value if Valid, or returns null if Invalid.
inherited
Operators
-
operator &(
Validated< T> other) → Validated<T> -
Combines two validation results, merging their errors.
inherited
-
operator ==(
Object other) → bool -
The equality operator.
override