mirror of
https://github.com/cypherstack/stack_wallet.git
synced 2025-05-03 03:12:18 +00:00
allow empty address forms in contact address form validation
This commit is contained in:
parent
f04018dbe6
commit
bd72f65fc9
2 changed files with 26 additions and 4 deletions
lib
models
providers/ui/address_book_providers
|
@ -33,6 +33,19 @@ class AddressEntryData extends ChangeNotifier {
|
||||||
notifyListeners();
|
notifyListeners();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool get isEmpty {
|
||||||
|
if (address != null && address!.isNotEmpty) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (addressLabel != null && addressLabel!.isNotEmpty) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (coin != null) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
bool get isValid {
|
bool get isValid {
|
||||||
if (_address == null || coin == null || _addressLabel == null) {
|
if (_address == null || coin == null || _addressLabel == null) {
|
||||||
return false;
|
return false;
|
||||||
|
|
|
@ -5,10 +5,19 @@ final validContactStateProvider =
|
||||||
StateProvider.autoDispose.family<bool, List<int>>((ref, ids) {
|
StateProvider.autoDispose.family<bool, List<int>>((ref, ids) {
|
||||||
bool isValid = true;
|
bool isValid = true;
|
||||||
|
|
||||||
|
bool hasAtLeastOneValid = false;
|
||||||
|
|
||||||
for (int i = 0; i < ids.length; i++) {
|
for (int i = 0; i < ids.length; i++) {
|
||||||
isValid = isValid &&
|
final _valid = ref.watch(
|
||||||
ref.watch(
|
addressEntryDataProvider(ids[i]).select((value) => value.isValid));
|
||||||
addressEntryDataProvider(ids[i]).select((value) => value.isValid));
|
|
||||||
|
final _isEmpty = ref.watch(
|
||||||
|
addressEntryDataProvider(ids[i]).select((value) => value.isEmpty));
|
||||||
|
|
||||||
|
isValid = isValid && (_valid || _isEmpty);
|
||||||
|
if (_valid) {
|
||||||
|
hasAtLeastOneValid = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return isValid;
|
return isValid && hasAtLeastOneValid;
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in a new issue