Compare commits

..

2 Commits

9 changed files with 36 additions and 20 deletions

View File

@ -73,7 +73,9 @@ class WyattFormImpl extends WyattForm {
if (containsKey(key)) { if (containsKey(key)) {
return inputs.firstWhere((input) => input.key == key); return inputs.firstWhere((input) => input.key == key);
} else { } 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]; List<Object?> get props => [_inputs, _name, _validator];
@override @override
String toString() => String toString() => 'WyattForm(name: $name, validation: '
'WyattForm(name: $name, validation: ${_validator.runtimeType}, inputs: $inputs)'; '${_validator.runtimeType}, inputs: $inputs)';
} }

View File

@ -41,4 +41,7 @@ class ConfirmedPassword
@override @override
ValidationStandardError get onNull => ValidationStandardError.invalid; ValidationStandardError get onNull => ValidationStandardError.invalid;
@override
List<Object?> get props => super.props + [password];
} }

View File

@ -57,4 +57,7 @@ class FormRepositoryImpl extends FormRepository {
void unregisterForm(String formName) { void unregisterForm(String formName) {
_runtimeForms.remove(formName); _runtimeForms.remove(formName);
} }
@override
String toString() => 'FormRepository($_runtimeForms)';
} }

View File

@ -63,5 +63,5 @@ class FormInput<
@override @override
String toString() => String toString() =>
'FormInput(name: $name, value: ${validator.value}, status: ${validator.status.name}'; 'FormInput(name: $name, $validator)';
} }

View File

@ -42,4 +42,10 @@ abstract class AnyValidator<O, I extends Iterable<O?>,
} }
return onError; return onError;
} }
@override
List<Object?> get props => super.props + [allChoices];
@override
String toString() => '${super.toString()}, choices: $allChoices';
} }

View File

@ -1,16 +1,16 @@
// Copyright (C) 2022 WYATT GROUP // Copyright (C) 2022 WYATT GROUP
// Please see the AUTHORS file for details. // Please see the AUTHORS file for details.
// //
// This program is free software: you can redistribute it and/or modify // This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by // it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or // the Free Software Foundation, either version 3 of the License, or
// any later version. // any later version.
// //
// This program is distributed in the hope that it will be useful, // This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of // but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details. // GNU General Public License for more details.
// //
// You should have received a copy of the GNU General Public License // You should have received a copy of the GNU General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>. // along with this program. If not, see <https://www.gnu.org/licenses/>.
@ -42,4 +42,10 @@ abstract class EqualityValidator<O extends Object, E extends ValidationError>
} }
return null; return null;
} }
@override
List<Object?> get props => super.props + [another];
@override
String toString() => '${super.toString()}, another: $another';
} }

View File

@ -107,8 +107,8 @@ abstract class FormInputValidator<Value, Error extends ValidationError>
Error? validator(Value? value); Error? validator(Value? value);
@override @override
bool? get stringify => true; List<Object?> get props => [value, pure];
@override @override
List<Object?> get props => [value, pure]; String toString() => 'value: $value, status: ${status.name}';
} }

View File

@ -16,24 +16,21 @@
part of 'form_data_cubit.dart'; part of 'form_data_cubit.dart';
// ignore: must_be_immutable
abstract class FormDataState extends Equatable { abstract class FormDataState extends Equatable {
/// Global status of a form. /// Global status of a form.
final FormStatus status; final FormStatus status;
/// FormData with all inputs, and associated metadata. /// FormData with all inputs, and associated metadata.
late WyattForm form; final WyattForm form;
/// Optional error message. /// Optional error message.
final String? errorMessage; final String? errorMessage;
FormDataState({ const FormDataState({
WyattForm? form, required this.form,
this.status = FormStatus.pure, this.status = FormStatus.pure,
this.errorMessage, this.errorMessage,
}) { });
this.form = form ?? WyattFormImpl(const [], name: '');
}
@override @override
List<Object?> get props => [status, form, errorMessage]; List<Object?> get props => [status, form, errorMessage];

View File

@ -16,9 +16,8 @@
part of 'form_data_cubit_impl.dart'; part of 'form_data_cubit_impl.dart';
// ignore: must_be_immutable
class FormDataStateImpl extends FormDataState { class FormDataStateImpl extends FormDataState {
FormDataStateImpl({ const FormDataStateImpl({
required super.form, required super.form,
super.status = FormStatus.pure, super.status = FormStatus.pure,
super.errorMessage, super.errorMessage,
@ -39,6 +38,6 @@ class FormDataStateImpl extends FormDataState {
List<Object?> get props => [status, form, errorMessage]; List<Object?> get props => [status, form, errorMessage];
@override @override
String toString() => String toString() => 'FormDataSate(status: ${status.name} '
'FormDataSate(status: ${status.name} ${(errorMessage != null) ? " [$errorMessage]" : ""}, $form'; '${(errorMessage != null) ? " [$errorMessage]" : ""}, $form)';
} }