Compare commits
2 Commits
0fd2dc3ddb
...
637f123c24
Author | SHA1 | Date | |
---|---|---|---|
637f123c24 | |||
6602e7eff6 |
@ -142,16 +142,17 @@ bool validateSettings(
|
||||
String? rootKey,
|
||||
}) {
|
||||
settings.forEach((key, value) {
|
||||
final checkKey = rootKey == null ? key : '$rootKey.$key';
|
||||
if (value is Map) {
|
||||
validateSettings(
|
||||
value as Map<String, dynamic>,
|
||||
failed,
|
||||
rootKey: rootKey == null ? key : '$rootKey.$key',
|
||||
rootKey: checkKey,
|
||||
);
|
||||
} else {
|
||||
for (var validator in getSettingValidators(key)) {
|
||||
for (var validator in getSettingValidators(checkKey)) {
|
||||
if (!validator(value.toString())) {
|
||||
failed.add(rootKey == null ? key : '$rootKey.$key');
|
||||
failed.add(checkKey);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -127,6 +127,11 @@ class _AddMountScreenState extends State<AddMountScreen> {
|
||||
onPressed: () {
|
||||
List<String> failed = [];
|
||||
if (!validateSettings(_settings[_mountType]!, failed)) {
|
||||
for (var key in failed) {
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
SnackBar(content: Text("'$key' is not valid")),
|
||||
);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user