ValidationReport.h File
Structured validation results for builder-level checks. More...
Included Headers
#include <cstdint>
#include <sstream>
#include <string>
#include <utility>
#include <vector>
Namespaces Index
| namespace | simaai |
| namespace | neat |
Classes Index
| struct | ValidationIssue |
| class | ValidationReport |
|
Report produced by running a ContractRegistry. More... | |
Description
Structured validation results for builder-level checks.
Defines ValidationSeverity, ValidationIssue, and ValidationReport — the data types that ContractRegistry::validate() produces. The report is STL-only and JSON-serializable so CI tools and dashboards can consume it without pulling in any framework dependencies.
- See Also
Contract
- See Also
ContractRegistry
File Listing
The file content with the documentation metadata removed is:
23namespace simaai::neat {
29enum class ValidationSeverity {
30 Info = 0,
31 Warning,
32 Error,
36inline const char* to_string(ValidationSeverity s) {
38 case ValidationSeverity::Info:
40 case ValidationSeverity::Warning:
42 case ValidationSeverity::Error:
57struct ValidationIssue {
61 std::string contract_id;
66 int node_index = -1;
68 std::string node_label;
82class ValidationReport final {
85 ValidationReport() = default;
90 void add_issue(ValidationIssue issue) {
97 add_issue({ValidationSeverity::Info, std::move(contract_id), std::move(code), std::move(msg),
102 void add_warning(std::string contract_id, std::string code, std::string msg, int node_index = -1,
104 add_issue({ValidationSeverity::Warning, std::move(contract_id), std::move(code), std::move(msg),
111 add_issue({ValidationSeverity::Error, std::move(contract_id), std::move(code), std::move(msg),
116 void note_contract_run(std::string id) {
122 mode_ = mode;
136 const std::vector<std::string>& contracts_run() const noexcept {
142 return !has_errors();
146 bool has_errors() const noexcept {
148 if (i.severity == ValidationSeverity::Error)
155 std::size_t error_count() const noexcept {
158 if (i.severity == ValidationSeverity::Error)
164 std::size_t warning_count() const noexcept {
167 if (i.severity == ValidationSeverity::Warning)
173 std::size_t info_count() const noexcept {
176 if (i.severity == ValidationSeverity::Info)
186 oss << (ok() ? "OK" : "FAILED") << " (errors=" << error_count()
187 << ", warnings=" << warning_count() << ", info=" << info_count() << ")\n";
190 oss << "- [" << ::simaai::neat::to_string(i.severity) << "] "
213 oss << "\"ok\":" << (ok() ? "true" : "false") << ",";
215 oss << "\"errors\":" << error_count() << ",";
216 oss << "\"warnings\":" << warning_count() << ",";
217 oss << "\"info\":" << info_count() << ",";
235 oss << "\"severity\":\"" << json_escape_(::simaai::neat::to_string(it.severity)) << "\",";
Generated via doxygen2docusaurus 2.0.0 by Doxygen 1.9.8.