agpm_cli/cli/validate/
results.rs

1//! Validation results structure for aggregating validation outcomes.
2
3use serde::Serialize;
4
5/// Results structure for validation operations, used primarily for JSON output.
6///
7/// This struct aggregates all validation results into a single structure that
8/// can be serialized to JSON for machine consumption. Each field represents
9/// the result of a specific validation check.
10///
11/// # Fields
12///
13/// - `valid`: Overall validation status (no errors, or warnings in strict mode)
14/// - `manifest_valid`: Whether the manifest file is syntactically valid
15/// - `dependencies_resolvable`: Whether all dependencies can be resolved
16/// - `sources_accessible`: Whether all source repositories are accessible
17/// - `local_paths_exist`: Whether all local file dependencies exist
18/// - `lockfile_consistent`: Whether the lockfile matches the manifest
19/// - `errors`: List of error messages that caused validation to fail
20/// - `warnings`: List of warning messages (non-fatal issues)
21///
22/// # JSON Output Example
23///
24/// ```json
25/// {
26///   "valid": true,
27///   "manifest_valid": true,
28///   "dependencies_resolvable": true,
29///   "sources_accessible": true,
30///   "local_paths_exist": true,
31///   "lockfile_consistent": false,
32///   "errors": [],
33///   "warnings": ["Lockfile is missing 2 dependencies"]
34/// }
35/// ```
36#[derive(Serialize)]
37pub struct ValidationResults {
38    /// Overall validation status - true if no errors (and no warnings in strict mode)
39    pub valid: bool,
40    /// Whether the manifest file syntax and structure is valid
41    pub manifest_valid: bool,
42    /// Whether all dependencies can be resolved to specific versions
43    pub dependencies_resolvable: bool,
44    /// Whether all source repositories are accessible via network
45    pub sources_accessible: bool,
46    /// Whether all local file dependencies point to existing files
47    pub local_paths_exist: bool,
48    /// Whether the lockfile is consistent with the manifest
49    pub lockfile_consistent: bool,
50    /// Whether all templates rendered successfully (when --render is used)
51    pub templates_valid: bool,
52    /// Number of templates successfully rendered
53    pub templates_rendered: usize,
54    /// Total number of templates found
55    pub templates_total: usize,
56    /// List of error messages that caused validation failure
57    pub errors: Vec<String>,
58    /// List of warning messages (non-fatal issues)
59    pub warnings: Vec<String>,
60}
61
62impl Default for ValidationResults {
63    fn default() -> Self {
64        Self {
65            valid: true, // Default to true as expected by test
66            manifest_valid: false,
67            dependencies_resolvable: false,
68            sources_accessible: false,
69            local_paths_exist: false,
70            lockfile_consistent: false,
71            templates_valid: false,
72            templates_rendered: 0,
73            templates_total: 0,
74            errors: Vec::new(),
75            warnings: Vec::new(),
76        }
77    }
78}