Assert<T> class
A decorator that allows adding assert(...)
on the generated classes.
Usage example:
@valueClass
class Email with _$Email {
@Assert(_checkNotEmpty, 'Email cannot be empty')
@Assert(_checkFormat, 'Email format is invalid')
factory Email(String value) = _Email;
factory Email.fromJson(String value) = _Email;
}
bool _checkNotEmpty(String value) => value.isNotEmpty;
bool _checkFormat(String value) => value.contains(RegExp(r'^.+@\S+\.\S+$'));
TODO: @Target({TargetKind.constructor}) see: https://github.com/dart-lang/sdk/issues/47421
Properties
Methods
-
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