validateManifest function
Validate a PluginManifest for required fields and consistency.
Implementation
ManifestValidationResult validateManifest(PluginManifest manifest) {
final errors = <String>[];
final warnings = <String>[];
if (manifest.name.isEmpty || manifest.name == 'unknown') {
errors.add('Plugin name is required');
}
if (manifest.version == '0.0.0') {
warnings.add('Plugin version defaults to 0.0.0');
}
if (manifest.description == null || manifest.description!.isEmpty) {
warnings.add('Plugin has no description');
}
// Name must be a valid identifier-like string.
final namePattern = RegExp(r'^[a-zA-Z0-9_-]+$');
if (!namePattern.hasMatch(manifest.name)) {
errors.add(
'Plugin name "${manifest.name}" contains invalid characters; '
'only alphanumerics, dashes, and underscores are allowed',
);
}
return ManifestValidationResult(
isValid: errors.isEmpty,
errors: errors,
warnings: warnings,
);
}