9#include <userver/formats/json/exception.hpp>
10#include <userver/formats/json/value.hpp>
11#include <userver/utils/fast_pimpl.hpp>
13USERVER_NAMESPACE_BEGIN
15namespace formats::
json {
20 SchemaValidationException(std::string_view msg, std::string_view path, std::string_view schema_path);
22 std::string_view GetSchemaPath()
const noexcept;
25 std::string schema_path_;
34 class ValidationResult;
35 class ValidationError;
37 explicit Schema(
const Value& doc);
42 ValidationResult Validate(
const Value& doc)
const;
46 static constexpr std::size_t kSize = 288;
47 static constexpr std::size_t kAlignment = 8;
48 utils::FastPimpl<Impl, kSize, kAlignment> impl_;
52class Schema::ValidationResult
final {
55 ValidationResult()
noexcept;
57 ValidationResult(ValidationResult&&)
noexcept;
58 ValidationResult& operator=(ValidationResult&&)
noexcept;
59 ~ValidationResult()
noexcept;
62 explicit operator
bool()
const noexcept;
65 bool IsValid()
const noexcept;
68 bool IsError()
const noexcept;
73 void ThrowIfError() &&;
76 ValidationError GetError() &&;
80 friend class ValidationError;
83 static constexpr std::size_t kSize = 24;
84 static constexpr std::size_t kAlignment = 8;
85 utils::FastPimpl<Impl, kSize, kAlignment> impl_;
88class Schema::ValidationError
final {
92 [[noreturn]]
void Throw()
const;
97 std::string_view GetValuePath()
const;
100 std::string_view GetSchemaPath()
const;
103 std::string_view GetDetailsString()
const;
106 friend class ValidationResult;
110 std::string value_path_;
111 std::string schema_path_;
112 std::string details_string_;