validate method
验证配置
Implementation
ConfigValidationResult validate() {
final errors = <String>[];
if (network != null && network!.baseUrl.isEmpty) {
errors.add('network.baseUrl 不能为空');
}
if (storage != null) {
final names = storage!.buckets.map((bucket) => bucket.name).toList();
if (names.isEmpty ||
names.toSet().length != names.length ||
!names.contains(storage!.defaultBucketName)) {
errors.add('storage 分区必须非空、名称唯一且包含默认分区');
}
}
if (i18n != null &&
storage == null &&
!StormyStorage.instance.isInitialized) {
errors.add('i18n 的语言持久化需要先配置 storage');
}
return errors.isEmpty
? ConfigValidationResult.valid()
: ConfigValidationResult.invalid(errors);
}