Skip to content

Commit 503ccb9

Browse files
committed
deps: update ata to 0.10.5 with format_prose helper
1 parent 372f61d commit 503ccb9

3 files changed

Lines changed: 15 additions & 13 deletions

File tree

deps/ata/ata.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2751,6 +2751,14 @@ validation_result validate(const schema_ref& schema, std::string_view json,
27512751
return {errors.empty(), std::move(errors)};
27522752
}
27532753

2754+
std::string format_prose(const validation_error& err) {
2755+
std::string path = err.path.empty() ? "/" : err.path;
2756+
if (err.code == error_code::type_mismatch && !err.expected.empty()) {
2757+
return path + " should be " + err.expected + ", got " + err.actual;
2758+
}
2759+
return path + " " + err.message;
2760+
}
2761+
27542762
validation_result validate(std::string_view schema_json,
27552763
std::string_view json,
27562764
const validate_options& opts) {

deps/ata/ata.h

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,16 +8,16 @@
88
#include <variant>
99
#include <vector>
1010

11-
#define ATA_VERSION "0.10.4"
11+
#define ATA_VERSION "0.10.5"
1212

1313
namespace ata {
1414

1515
inline constexpr uint32_t VERSION_MAJOR = 0;
1616
inline constexpr uint32_t VERSION_MINOR = 10;
17-
inline constexpr uint32_t VERSION_REVISION = 4;
17+
inline constexpr uint32_t VERSION_REVISION = 5;
1818

1919
inline constexpr std::string_view version() noexcept {
20-
return "0.10.4";
20+
return "0.10.5";
2121
}
2222

2323
enum class error_code : uint8_t {
@@ -91,6 +91,9 @@ schema_ref compile(std::string_view schema_json);
9191
validation_result validate(const schema_ref& schema, std::string_view json,
9292
const validate_options& opts = {});
9393

94+
// Format a validation_error as a single-line prose sentence.
95+
std::string format_prose(const validation_error& err);
96+
9497
// Validate a JSON document against a schema (compiles schema each time).
9598
validation_result validate(std::string_view schema_json,
9699
std::string_view json,

src/node_config_file.cc

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -244,16 +244,7 @@ ParseResult ConfigReader::ParseConfig(const std::string_view& config_path) {
244244
if (!result.valid) {
245245
FPrintF(stderr, "Invalid configuration in %s:\n", config_path.data());
246246
for (const auto& err : result.errors) {
247-
const char* path = err.path.empty() ? "/" : err.path.c_str();
248-
if (err.code == ata::error_code::type_mismatch) {
249-
FPrintF(stderr,
250-
" %s should be %s, got %s\n",
251-
path,
252-
err.expected,
253-
err.actual);
254-
} else {
255-
FPrintF(stderr, " %s: %s\n", path, err.message);
256-
}
247+
FPrintF(stderr, " %s\n", ata::format_prose(err));
257248
}
258249
return ParseResult::InvalidContent;
259250
}

0 commit comments

Comments
 (0)