Hi
I’ve run into what looks like a bug with the built-in rfl::UUIDv4 pattern type when it’s used directly as a struct field.
Minimal repro (GoogleTest)
#include <gtest/gtest.h>
#include <rfl/json.hpp>
#include <rfl/patterns.hpp>
struct Request {
rfl::UUIDv4 id;
std::string command;
std::optional<std::string> payload;
static inline auto fromJson(std::string_view v) {
return rfl::json::read<Request>(v);
}
};
TEST(RequestParsing, UuidV4FieldFails) {
const char *js = R"({
"command":"PING",
"id":"f23b2a1d-b1a6-4e0d-af1b-8f0d912e255a"
})";
auto req = Request::fromJson(js);
// This *should* succeed because the UUID is valid v4, but it fails.
EXPECT_TRUE(req.has_value())
<< "Parse failed: " << (req ? "" : req.error().what());
}
Observed behavior
The test fails with:
Parse failed: Failed to parse field 'id': String 'f23b2a1d-b1a6-4e0d-af1b-8f0d912e255a' did not match format 'UUIDv4': '^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-4[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}$'
…but the UUID clearly matches the regex.
Expected behavior
The JSON should parse successfully.
Hi
I’ve run into what looks like a bug with the built-in
rfl::UUIDv4pattern type when it’s used directly as a struct field.Minimal repro (GoogleTest)
Observed behavior
The test fails with:
…but the UUID clearly matches the regex.
Expected behavior
The JSON should parse successfully.