fix(form)!: change validate() to selfValidate()
This commit is contained in:
parent
b6b42f9366
commit
703e3deeaf
packages/wyatt_form_bloc
@ -44,7 +44,7 @@ class FormDataCubit extends Cubit<FormDataState> {
|
||||
emit(
|
||||
state.copyWith(
|
||||
data: _form,
|
||||
status: _form.validate(),
|
||||
status: _form.selfValidate(),
|
||||
),
|
||||
);
|
||||
}
|
||||
@ -73,7 +73,7 @@ class FormDataCubit extends Cubit<FormDataState> {
|
||||
emit(
|
||||
state.copyWith(
|
||||
data: _form,
|
||||
status: _form.validate(),
|
||||
status: _form.selfValidate(),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
@ -18,7 +18,6 @@ import 'package:meta/meta.dart';
|
||||
import 'package:wyatt_form_bloc/src/enums/enums.dart';
|
||||
import 'package:wyatt_form_bloc/src/form/form.dart';
|
||||
import 'package:wyatt_form_bloc/src/utils/list_equals.dart';
|
||||
import 'package:wyatt_form_bloc/src/validators/validators.dart';
|
||||
|
||||
@immutable
|
||||
class FormData {
|
||||
@ -36,9 +35,7 @@ class FormData {
|
||||
.toList();
|
||||
}
|
||||
|
||||
FormStatus validate() {
|
||||
final List<FormInput> inputs = this.inputs<dynamic>();
|
||||
|
||||
static FormStatus validate(List<FormInput> inputs) {
|
||||
return inputs.every((FormInput element) => element.pure)
|
||||
? FormStatus.pure
|
||||
: inputs.any((FormInput input) => input.valid == false)
|
||||
@ -46,6 +43,10 @@ class FormData {
|
||||
: FormStatus.valid;
|
||||
}
|
||||
|
||||
FormStatus selfValidate() {
|
||||
return validate(inputs<dynamic>());
|
||||
}
|
||||
|
||||
FormInput<T, ValidationError> input<T>(String key) {
|
||||
if (contains(key)) {
|
||||
return _entries.firstWhere((FormEntry entry) => entry.key == key).input
|
||||
|
@ -1,5 +1,6 @@
|
||||
name: wyatt_form_bloc
|
||||
description: Manage forms in a Flutter app with Bloc
|
||||
description: Manage forms in Dart & Flutter with Bloc
|
||||
repository: https://git.wyatt-studio.fr/Wyatt-FOSS/wyatt-packages/src/branch/master/packages/wyatt_form_bloc
|
||||
version: 0.0.1-dev.0
|
||||
|
||||
environment:
|
||||
|
Loading…
x
Reference in New Issue
Block a user