constraint.h 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539
  1. #pragma once
  2. #include <functional>
  3. #include <map>
  4. #include <memory>
  5. #include <set>
  6. #include <string_view>
  7. #include <unordered_map>
  8. #include <unordered_set>
  9. #include <jvalidate/constraint/array_constraint.h>
  10. #include <jvalidate/constraint/general_constraint.h>
  11. #include <jvalidate/constraint/number_constraint.h>
  12. #include <jvalidate/constraint/object_constraint.h>
  13. #include <jvalidate/constraint/string_constraint.h>
  14. #include <jvalidate/detail/expect.h>
  15. #include <jvalidate/detail/parser_context.h>
  16. #include <jvalidate/enum.h>
  17. #include <jvalidate/forward.h>
  18. namespace jvalidate {
  19. template <Adapter A> class ConstraintFactory {
  20. public:
  21. using pConstraint = std::unique_ptr<constraint::Constraint>;
  22. using Object = decltype(std::declval<A>().as_object());
  23. using MakeConstraint = std::function<pConstraint(detail::ParserContext<A> const &)>;
  24. template <typename V> using Versioned = std::map<schema::Version, V, std::greater<>>;
  25. template <typename V> using Keywords = std::unordered_map<std::string_view, V>;
  26. private:
  27. using Self = ConstraintFactory<A>;
  28. private:
  29. Keywords<MakeConstraint> constraints_{
  30. {"additionalProperties", &Self::additionalProperties},
  31. {"enum", &Self::isInEnumuration},
  32. {"maxItems", &Self::maxItems},
  33. {"maxLength", &Self::maxLength},
  34. {"maximum", &Self::maximum},
  35. {"minItems", &Self::minItems},
  36. {"minLength", &Self::minLength},
  37. {"minimum", &Self::minimum},
  38. {"pattern", &Self::pattern},
  39. {"patternProperties", &Self::patternProperties},
  40. {"properties", &Self::properties},
  41. {"type", &Self::type},
  42. {"uniqueItems", &Self::uniqueItems},
  43. };
  44. Keywords<Versioned<MakeConstraint>> versioned_constraints_{
  45. {"additionalItems",
  46. {{schema::Version::Draft04, &Self::additionalItems},
  47. {schema::Version::Draft2020_12, nullptr}}},
  48. {"allOf", {{schema::Version::Draft04, &Self::allOf}}},
  49. {"anyOf", {{schema::Version::Draft04, &Self::anyOf}}},
  50. {"const", {{schema::Version::Draft06, &Self::isConstant}}},
  51. {"contains", {{schema::Version::Draft06, &Self::contains}}},
  52. {"dependencies",
  53. {{schema::Version::Draft04, &Self::dependencies}, {schema::Version::Draft2019_09, nullptr}}},
  54. {"dependentRequired", {{schema::Version::Draft2019_09, &Self::dependentRequired}}},
  55. {"dependentSchemas", {{schema::Version::Draft2019_09, &Self::dependentSchemas}}},
  56. {"divisibleBy",
  57. {{schema::Version::Draft04, &Self::multipleOf}, {schema::Version::Draft04, nullptr}}},
  58. {"exclusiveMaximum", {{schema::Version::Draft06, &Self::exclusiveMaximum}}},
  59. {"exclusiveMinimum", {{schema::Version::Draft06, &Self::exclusiveMinimum}}},
  60. {"format",
  61. {{schema::Version::Draft04, &Self::warnUnimplemented},
  62. {schema::Version::Draft2020_12, nullptr}}},
  63. {"format-assertion", {{schema::Version::Draft2020_12, &Self::fatalUnimplemented}}},
  64. {"if", {{schema::Version::Draft07, &Self::ifThenElse}}},
  65. {"items",
  66. {{schema::Version::Draft04, &Self::itemsTupleOrVector},
  67. {schema::Version::Draft2020_12, &Self::additionalItems}}},
  68. {"maxProperties", {{schema::Version::Draft04, &Self::maxProperties}}},
  69. {"minProperties", {{schema::Version::Draft04, &Self::minProperties}}},
  70. {"multipleOf", {{schema::Version::Draft04, &Self::multipleOf}}},
  71. {"not", {{schema::Version::Draft04, &Self::isNot}}},
  72. {"oneOf", {{schema::Version::Draft04, &Self::oneOf}}},
  73. {"prefixItems", {{schema::Version::Draft2020_12, &Self::prefixItems}}},
  74. {"propertyNames", {{schema::Version::Draft06, &Self::propertyNames}}},
  75. {"required", {{schema::Version::Draft04, &Self::required}}},
  76. {"unevaluatedItems", {{schema::Version::Draft2019_09, &Self::unevaluatedItems}}},
  77. {"unevaluatedProperties", {{schema::Version::Draft2019_09, &Self::unevaluatedProperties}}},
  78. };
  79. Keywords<Versioned<std::set<schema::Wraps>>> keywords_{
  80. {"$defs", {{schema::Version::Draft2019_09, {schema::Wraps::Object}}}},
  81. {"additionalItems",
  82. {{schema::Version::Draft04, {schema::Wraps::Schema}}, {schema::Version::Draft2020_12, {}}}},
  83. {"additionalProperties", {{schema::Version::Draft04, {schema::Wraps::Schema}}}},
  84. {"allOf", {{schema::Version::Draft04, {schema::Wraps::Array}}}},
  85. {"anyOf", {{schema::Version::Draft04, {schema::Wraps::Array}}}},
  86. {"definitions",
  87. {{schema::Version::Draft04, {schema::Wraps::Object}}, {schema::Version::Draft2019_09, {}}}},
  88. {"dependencies",
  89. {{schema::Version::Draft04, {schema::Wraps::Object}}, {schema::Version::Draft2019_09, {}}}},
  90. {"dependentSchemas", {{schema::Version::Draft2019_09, {schema::Wraps::Object}}}},
  91. {"else", {{schema::Version::Draft04, {schema::Wraps::Schema}}}},
  92. {"if", {{schema::Version::Draft04, {schema::Wraps::Schema}}}},
  93. {"items",
  94. {{schema::Version::Draft04, {schema::Wraps::Array, schema::Wraps::Schema}},
  95. {schema::Version::Draft2020_12, {schema::Wraps::Schema}}}},
  96. {"not", {{schema::Version::Draft04, {schema::Wraps::Schema}}}},
  97. {"oneOf", {{schema::Version::Draft04, {schema::Wraps::Array}}}},
  98. {"patternProperties", {{schema::Version::Draft04, {schema::Wraps::Object}}}},
  99. {"prefixItems", {{schema::Version::Draft2020_12, {schema::Wraps::Array}}}},
  100. {"properties", {{schema::Version::Draft04, {schema::Wraps::Object}}}},
  101. {"then", {{schema::Version::Draft04, {schema::Wraps::Schema}}}},
  102. {"unevaluatedItems", {{schema::Version::Draft2020_12, {schema::Wraps::Schema}}}},
  103. {"unevaluatedProperties", {{schema::Version::Draft2020_12, {schema::Wraps::Schema}}}},
  104. };
  105. public:
  106. ConstraintFactory() = default;
  107. explicit ConstraintFactory(
  108. Keywords<MakeConstraint> const & user_keywords,
  109. Keywords<Versioned<MakeConstraint>> const & user_versioned_keywords = {}) {
  110. constraints_.insert(constraints_.end(), user_keywords.begin(), user_keywords.end());
  111. versioned_constraints_.insert(versioned_constraints_.end(), user_versioned_keywords.begin(),
  112. user_versioned_keywords.end());
  113. }
  114. bool is_post_constraint(std::string_view key) const {
  115. return key == "unevaluatedItems" || key == "unevaluatedProperties";
  116. }
  117. Keywords<std::set<schema::Wraps>> keywords(schema::Version version) const {
  118. Keywords<std::set<schema::Wraps>> rval;
  119. for (auto const & [key, versions] : keywords_) {
  120. if (auto it = versions.lower_bound(version); it != versions.end()) {
  121. rval.emplace(key, it->second);
  122. }
  123. }
  124. return rval;
  125. }
  126. MakeConstraint operator()(std::string_view key, schema::Version version) const {
  127. if (auto it = constraints_.find(key); it != constraints_.end()) {
  128. return it->second;
  129. }
  130. if (auto it = versioned_constraints_.find(key); it != versioned_constraints_.end()) {
  131. if (auto vit = it->second.lower_bound(version); vit != it->second.end()) {
  132. return vit->second;
  133. }
  134. }
  135. return nullptr;
  136. }
  137. // SECTION: Untyped Constraints
  138. static pConstraint warnUnimplemented(detail::ParserContext<A> const & context) {
  139. std::cerr << "Unimplemented constraint " << context.where << "\n";
  140. return nullptr;
  141. }
  142. static pConstraint fatalUnimplemented(detail::ParserContext<A> const & context) {
  143. JVALIDATE_THROW(std::runtime_error, "Unimplemented constraint " << context.where);
  144. }
  145. static auto type(detail::ParserContext<A> const & context) {
  146. static std::unordered_map<std::string_view, adapter::Type> const s_type_names{
  147. {"null", adapter::Type::Null}, {"boolean", adapter::Type::Boolean},
  148. {"integer", adapter::Type::Integer}, {"number", adapter::Type::Number},
  149. {"string", adapter::Type::String}, {"array", adapter::Type::Array},
  150. {"object", adapter::Type::Object},
  151. };
  152. auto to_type = [](std::string_view type) {
  153. EXPECT_M(s_type_names.contains(type), "Unknown type " << type);
  154. return s_type_names.at(type);
  155. };
  156. adapter::Type const type = context.schema.type();
  157. if (type == adapter::Type::String) {
  158. return std::make_unique<constraint::TypeConstraint>(to_type(context.schema.as_string()));
  159. }
  160. EXPECT(type == adapter::Type::Array);
  161. std::set<adapter::Type> types;
  162. for (auto subschema : context.schema.as_array()) {
  163. types.insert(to_type(subschema.as_string()));
  164. }
  165. return std::make_unique<constraint::TypeConstraint>(types);
  166. }
  167. static pConstraint ifThenElse(detail::ParserContext<A> const & context) {
  168. schema::Node const * then_ = context.fixed_schema(true);
  169. if (context.parent->contains("then")) {
  170. then_ = context.neighbor("then").node();
  171. }
  172. schema::Node const * else_ = context.fixed_schema(true);
  173. if (context.parent->contains("else")) {
  174. else_ = context.neighbor("else").node();
  175. }
  176. if (then_ == else_) {
  177. return nullptr;
  178. }
  179. return std::make_unique<constraint::ConditionalConstraint>(context.node(), then_, else_);
  180. }
  181. static auto isInEnumuration(detail::ParserContext<A> const & context) {
  182. EXPECT(context.schema.type() == adapter::Type::Array);
  183. std::vector<std::unique_ptr<adapter::Const const>> rval;
  184. for (auto subschema : context.schema.as_array()) {
  185. rval.push_back(subschema.freeze());
  186. }
  187. return std::make_unique<constraint::EnumConstraint>(std::move(rval));
  188. }
  189. static auto isConstant(detail::ParserContext<A> const & context) {
  190. return std::make_unique<constraint::EnumConstraint>(context.schema.freeze());
  191. }
  192. static auto allOf(detail::ParserContext<A> const & context) {
  193. EXPECT(context.schema.type() == adapter::Type::Array);
  194. std::vector<schema::Node const *> rval;
  195. size_t index = 0;
  196. for (auto subschema : context.schema.as_array()) {
  197. rval.push_back(context.child(subschema, index).node());
  198. ++index;
  199. }
  200. return std::make_unique<constraint::AllOfConstraint>(rval);
  201. }
  202. static auto anyOf(detail::ParserContext<A> const & context) {
  203. EXPECT(context.schema.type() == adapter::Type::Array);
  204. std::vector<schema::Node const *> rval;
  205. size_t index = 0;
  206. for (auto subschema : context.schema.as_array()) {
  207. rval.push_back(context.child(subschema, index).node());
  208. ++index;
  209. }
  210. return std::make_unique<constraint::AnyOfConstraint>(rval);
  211. }
  212. static auto oneOf(detail::ParserContext<A> const & context) {
  213. EXPECT(context.schema.type() == adapter::Type::Array);
  214. std::vector<schema::Node const *> rval;
  215. size_t index = 0;
  216. for (auto subschema : context.schema.as_array()) {
  217. rval.push_back(context.child(subschema, index).node());
  218. ++index;
  219. }
  220. return std::make_unique<constraint::OneOfConstraint>(rval);
  221. }
  222. static auto isNot(detail::ParserContext<A> const & context) {
  223. return std::make_unique<constraint::NotConstraint>(context.node());
  224. }
  225. // SECTION: Numeric Constraints
  226. static auto minimum(detail::ParserContext<A> const & context) {
  227. double value = context.schema.as_number();
  228. if (context.version < schema::Version::Draft06 &&
  229. context.parent->contains("exclusiveMinimum")) {
  230. auto exclusive = (*context.parent)["exclusiveMinimum"];
  231. EXPECT(exclusive.type() == adapter::Type::Boolean);
  232. return std::make_unique<constraint::MinimumConstraint>(value, exclusive.as_boolean());
  233. }
  234. return std::make_unique<constraint::MinimumConstraint>(value, false);
  235. }
  236. static pConstraint exclusiveMinimum(detail::ParserContext<A> const & context) {
  237. double value = context.schema.as_number();
  238. return std::make_unique<constraint::MinimumConstraint>(value, true);
  239. }
  240. static auto maximum(detail::ParserContext<A> const & context) {
  241. double value = context.schema.as_number();
  242. if (context.version < schema::Version::Draft06 &&
  243. context.parent->contains("exclusiveMaximum")) {
  244. auto exclusive = (*context.parent)["exclusiveMaximum"];
  245. EXPECT(exclusive.type() == adapter::Type::Boolean);
  246. return std::make_unique<constraint::MaximumConstraint>(value, exclusive.as_boolean());
  247. }
  248. return std::make_unique<constraint::MaximumConstraint>(value, false);
  249. }
  250. static pConstraint exclusiveMaximum(detail::ParserContext<A> const & context) {
  251. double value = context.schema.as_number();
  252. return std::make_unique<constraint::MaximumConstraint>(value, true);
  253. }
  254. static auto multipleOf(detail::ParserContext<A> const & context) {
  255. double value = context.schema.as_number();
  256. return std::make_unique<constraint::MultipleOfConstraint>(value);
  257. }
  258. // SECTION: String Constraints
  259. static auto minLength(detail::ParserContext<A> const & context) {
  260. EXPECT(context.schema.type() == adapter::Type::Integer ||
  261. context.schema.type() == adapter::Type::Number);
  262. return std::make_unique<constraint::MinLengthConstraint>(context.schema.as_integer());
  263. }
  264. static auto maxLength(detail::ParserContext<A> const & context) {
  265. EXPECT(context.schema.type() == adapter::Type::Integer ||
  266. context.schema.type() == adapter::Type::Number);
  267. return std::make_unique<constraint::MaxLengthConstraint>(context.schema.as_integer());
  268. }
  269. static auto pattern(detail::ParserContext<A> const & context) {
  270. return std::make_unique<constraint::PatternConstraint>(context.schema.as_string());
  271. }
  272. // SECTION: Array Constraints
  273. static auto contains(detail::ParserContext<A> const & context) {
  274. if (context.version < schema::Version::Draft2019_09) {
  275. return std::make_unique<constraint::ContainsConstraint>(context.node());
  276. }
  277. std::optional<size_t> maximum;
  278. std::optional<size_t> minimum;
  279. if (context.parent->contains("maxContains")) {
  280. maximum = (*context.parent)["maxContains"].as_integer();
  281. }
  282. if (context.parent->contains("minContains")) {
  283. minimum = (*context.parent)["minContains"].as_integer();
  284. }
  285. return std::make_unique<constraint::ContainsConstraint>(context.node(), minimum, maximum);
  286. }
  287. static auto minItems(detail::ParserContext<A> const & context) {
  288. EXPECT(context.schema.type() == adapter::Type::Integer ||
  289. context.schema.type() == adapter::Type::Number);
  290. return std::make_unique<constraint::MinItemsConstraint>(context.schema.as_integer());
  291. }
  292. static auto maxItems(detail::ParserContext<A> const & context) {
  293. EXPECT(context.schema.type() == adapter::Type::Integer ||
  294. context.schema.type() == adapter::Type::Number);
  295. return std::make_unique<constraint::MaxItemsConstraint>(context.schema.as_integer());
  296. }
  297. static auto prefixItems(detail::ParserContext<A> const & context) {
  298. EXPECT(context.schema.type() == adapter::Type::Array);
  299. std::vector<schema::Node const *> rval;
  300. size_t index = 0;
  301. for (auto subschema : context.schema.as_array()) {
  302. rval.push_back(context.child(subschema, index).node());
  303. ++index;
  304. }
  305. return std::make_unique<constraint::TupleConstraint>(rval);
  306. }
  307. static auto additionalItemsAfter(detail::ParserContext<A> const & context, size_t n) {
  308. using C = constraint::AdditionalItemsConstraint;
  309. if (context.version < schema::Version::Draft06 &&
  310. context.schema.type() == adapter::Type::Boolean) {
  311. return std::make_unique<C>(context.always(), n);
  312. }
  313. return std::make_unique<C>(context.node(), n);
  314. }
  315. static pConstraint additionalItems(detail::ParserContext<A> const & context) {
  316. std::string const prefix =
  317. context.version >= schema::Version::Draft2020_12 ? "prefixItems" : "items";
  318. Object const & parent = *context.parent;
  319. // Before Draft 2020-12, the "items" could be either a subschema or a tuple.
  320. // When not provided, we therefore treat it as an "accept-all" schema, and
  321. // thus will never have additionalItems to process. Similarly - if it is an
  322. // Object, then it must act on all items.
  323. if (context.version < schema::Version::Draft2020_12 &&
  324. (not parent.contains(prefix) || parent[prefix].type() == adapter::Type::Object)) {
  325. return nullptr;
  326. }
  327. return additionalItemsAfter(context, parent[prefix].array_size());
  328. }
  329. static pConstraint itemsTupleOrVector(detail::ParserContext<A> const & context) {
  330. if (context.schema.type() == adapter::Type::Array) {
  331. return prefixItems(context);
  332. }
  333. return additionalItemsAfter(context, 0);
  334. }
  335. static auto unevaluatedItems(detail::ParserContext<A> const & context) {
  336. return std::make_unique<constraint::UnevaluatedItemsConstraint>(context.node());
  337. }
  338. static pConstraint uniqueItems(detail::ParserContext<A> const & context) {
  339. EXPECT(context.schema.type() == adapter::Type::Boolean);
  340. if (not context.schema.as_boolean()) {
  341. return nullptr;
  342. }
  343. return std::make_unique<constraint::UniqueItemsConstraint>();
  344. }
  345. // SECTION: Object Constraints
  346. static auto required(detail::ParserContext<A> const & context) {
  347. EXPECT(context.schema.type() == adapter::Type::Array);
  348. std::unordered_set<std::string> rval;
  349. for (auto subschema : context.schema.as_array()) {
  350. EXPECT(subschema.type() == adapter::Type::String);
  351. rval.insert(subschema.as_string());
  352. }
  353. return std::make_unique<constraint::RequiredConstraint>(rval);
  354. }
  355. static auto minProperties(detail::ParserContext<A> const & context) {
  356. EXPECT(context.schema.type() == adapter::Type::Integer ||
  357. context.schema.type() == adapter::Type::Number);
  358. return std::make_unique<constraint::MinPropertiesConstraint>(context.schema.as_integer());
  359. }
  360. static auto maxProperties(detail::ParserContext<A> const & context) {
  361. EXPECT(context.schema.type() == adapter::Type::Integer ||
  362. context.schema.type() == adapter::Type::Number);
  363. return std::make_unique<constraint::MaxPropertiesConstraint>(context.schema.as_integer());
  364. }
  365. static auto patternProperties(detail::ParserContext<A> const & context) {
  366. EXPECT(context.schema.type() == adapter::Type::Object);
  367. std::vector<std::pair<std::string, schema::Node const *>> rval;
  368. for (auto [prop, subschema] : context.schema.as_object()) {
  369. rval.emplace_back(prop, context.child(subschema, prop).node());
  370. }
  371. return std::make_unique<constraint::PatternPropertiesConstraint>(rval);
  372. }
  373. static auto properties(detail::ParserContext<A> const & context) {
  374. EXPECT(context.schema.type() == adapter::Type::Object);
  375. std::map<std::string, schema::Node const *> rval;
  376. for (auto [prop, subschema] : context.schema.as_object()) {
  377. rval.emplace(prop, context.child(subschema, prop).node());
  378. }
  379. return std::make_unique<constraint::PropertiesConstraint>(rval);
  380. }
  381. static auto propertyNames(detail::ParserContext<A> const & context) {
  382. return std::make_unique<constraint::PropertyNamesConstraint>(context.node());
  383. }
  384. static auto unevaluatedProperties(detail::ParserContext<A> const & context) {
  385. return std::make_unique<constraint::UnevaluatedPropertiesConstraint>(context.node());
  386. }
  387. static auto additionalProperties(detail::ParserContext<A> const & context) {
  388. std::unordered_set<std::string> properties;
  389. std::vector<std::string> patterns;
  390. Object const & parent = *context.parent;
  391. if (parent.contains("properties")) {
  392. for (auto [key, _] : parent["properties"].as_object()) {
  393. properties.insert(key);
  394. }
  395. }
  396. if (parent.contains("patternProperties")) {
  397. for (auto [key, _] : parent["patternProperties"].as_object()) {
  398. patterns.push_back(key);
  399. }
  400. }
  401. using C = constraint::AdditionalPropertiesConstraint;
  402. if (context.version < schema::Version::Draft06 &&
  403. context.schema.type() == adapter::Type::Boolean) {
  404. return std::make_unique<C>(context.always(), properties, patterns);
  405. }
  406. return std::make_unique<C>(context.node(), properties, patterns);
  407. }
  408. static auto dependencies(detail::ParserContext<A> const & context) {
  409. EXPECT(context.schema.type() == adapter::Type::Object);
  410. std::map<std::string, schema::Node const *> schemas;
  411. std::map<std::string, std::unordered_set<std::string>> required;
  412. for (auto [prop, subschema] : context.schema.as_object()) {
  413. if (subschema.type() == adapter::Type::Array) {
  414. for (auto key : subschema.as_array()) {
  415. EXPECT(key.type() == adapter::Type::String);
  416. required[prop].insert(key.as_string());
  417. }
  418. } else {
  419. schemas.emplace(prop, context.child(subschema, prop).node());
  420. }
  421. }
  422. return std::make_unique<constraint::DependenciesConstraint>(schemas, required);
  423. }
  424. static auto dependentSchemas(detail::ParserContext<A> const & context) {
  425. EXPECT(context.schema.type() == adapter::Type::Object);
  426. std::map<std::string, schema::Node const *> rval;
  427. for (auto [prop, subschema] : context.schema.as_object()) {
  428. rval.emplace(prop, context.child(subschema, prop).node());
  429. }
  430. return std::make_unique<constraint::DependenciesConstraint>(rval);
  431. }
  432. static auto dependentRequired(detail::ParserContext<A> const & context) {
  433. EXPECT(context.schema.type() == adapter::Type::Object);
  434. std::map<std::string, std::unordered_set<std::string>> rval;
  435. for (auto [prop, subschema] : context.schema.as_object()) {
  436. EXPECT(subschema.type() == adapter::Type::Array);
  437. for (auto key : subschema.as_array()) {
  438. EXPECT(key.type() == adapter::Type::String);
  439. rval[prop].insert(key.as_string());
  440. }
  441. }
  442. return std::make_unique<constraint::DependenciesConstraint>(rval);
  443. }
  444. };
  445. }