Browse Source

refactor: add ValidationResult::valid, ExtensionConstraint::make

Sam Jaffe 3 months ago
parent
commit
8195d931a6

+ 6 - 0
include/jvalidate/constraint/extension_constraint.h

@@ -13,6 +13,12 @@ public:
     virtual Status visit(extension::VisitorBase const &) const = 0;
   };
 
+public:
+  template <typename T, typename... Args> static std::unique_ptr<Constraint> make(Args &&... args) {
+    return std::make_unique<Constraint>(
+        ExtensionConstraint{std::make_unique<T>(std::forward<Args>(args)...)});
+  }
+
 public:
   std::unique_ptr<Impl> pimpl;
 };

+ 2 - 0
include/jvalidate/validation_result.h

@@ -134,6 +134,8 @@ public:
     os << indent(i) << '}';
   }
 
+  bool valid() const { return valid_; }
+
   /**
    * @brief Are there any validation details associated with the given document
    * location and schema section.