validate static method
Validate all pipelines and return a list of issues found. Returns an empty list if everything is valid.
Implementation
static List<PipelineValidationError> validate(
Map<String, PipelineModel> pipelines) {
final errors = <PipelineValidationError>[];
if (pipelines.isEmpty) {
errors.add(PipelineValidationError(
pipelineName: '(none)',
message: 'No pipelines defined. Add at least one pipeline with steps.',
));
return errors;
}
for (final entry in pipelines.entries) {
final pipelineName = entry.key;
final pipeline = entry.value;
// Check for empty steps
if (pipeline.steps.isEmpty) {
errors.add(PipelineValidationError(
pipelineName: pipelineName,
message:
'Pipeline has no steps. Add at least one step with "name" and "command".',
));
continue;
}
// Check for duplicate step names within a pipeline
final stepNames = <String>{};
for (final step in pipeline.steps) {
if (!stepNames.add(step.name)) {
errors.add(PipelineValidationError(
pipelineName: pipelineName,
stepName: step.name,
message:
'Duplicate step name. Each step within a pipeline must have a unique name.',
));
}
}
// Validate each step
for (final step in pipeline.steps) {
_validateStep(pipelineName, step, stepNames, errors);
}
}
return errors;
}