feat(form): clean and add toString and equality
This commit is contained in:
parent
ae3711a136
commit
0c920e8245
@ -73,7 +73,9 @@ class WyattFormImpl extends WyattForm {
|
||||
if (containsKey(key)) {
|
||||
return inputs.firstWhere((input) => input.key == key);
|
||||
} else {
|
||||
throw Exception('FormInput with key `$key` does not exist in form');
|
||||
throw Exception(
|
||||
'FormInput with key `$key` does not exist in form `$name`',
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@ -146,6 +148,6 @@ class WyattFormImpl extends WyattForm {
|
||||
List<Object?> get props => [_inputs, _name, _validator];
|
||||
|
||||
@override
|
||||
String toString() =>
|
||||
'WyattForm(name: $name, validation: ${_validator.runtimeType}, inputs: $inputs)';
|
||||
String toString() => 'WyattForm(name: $name, validation: '
|
||||
'${_validator.runtimeType}, inputs: $inputs)';
|
||||
}
|
||||
|
@ -41,4 +41,7 @@ class ConfirmedPassword
|
||||
|
||||
@override
|
||||
ValidationStandardError get onNull => ValidationStandardError.invalid;
|
||||
|
||||
@override
|
||||
List<Object?> get props => super.props + [password];
|
||||
}
|
||||
|
@ -57,4 +57,7 @@ class FormRepositoryImpl extends FormRepository {
|
||||
void unregisterForm(String formName) {
|
||||
_runtimeForms.remove(formName);
|
||||
}
|
||||
|
||||
@override
|
||||
String toString() => 'FormRepository($_runtimeForms)';
|
||||
}
|
||||
|
@ -63,5 +63,5 @@ class FormInput<
|
||||
|
||||
@override
|
||||
String toString() =>
|
||||
'FormInput(name: $name, value: ${validator.value}, status: ${validator.status.name}';
|
||||
'FormInput(name: $name, $validator)';
|
||||
}
|
||||
|
@ -42,4 +42,10 @@ abstract class AnyValidator<O, I extends Iterable<O?>,
|
||||
}
|
||||
return onError;
|
||||
}
|
||||
|
||||
@override
|
||||
List<Object?> get props => super.props + [allChoices];
|
||||
|
||||
@override
|
||||
String toString() => '${super.toString()}, choices: $allChoices';
|
||||
}
|
||||
|
@ -42,4 +42,10 @@ abstract class EqualityValidator<O extends Object, E extends ValidationError>
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@override
|
||||
List<Object?> get props => super.props + [another];
|
||||
|
||||
@override
|
||||
String toString() => '${super.toString()}, another: $another';
|
||||
}
|
||||
|
@ -107,8 +107,8 @@ abstract class FormInputValidator<Value, Error extends ValidationError>
|
||||
Error? validator(Value? value);
|
||||
|
||||
@override
|
||||
bool? get stringify => true;
|
||||
List<Object?> get props => [value, pure];
|
||||
|
||||
@override
|
||||
List<Object?> get props => [value, pure];
|
||||
String toString() => 'value: $value, status: ${status.name}';
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user