lutaml-model 0.8.186 → 0.8.188

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (308) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/dependent-repos-tools-informational.json +8 -0
  3. data/.github/workflows/dependent-repos-tools.json +1 -5
  4. data/.github/workflows/dependent-tests.yml +26 -2
  5. data/Gemfile +2 -0
  6. data/Rakefile +6 -0
  7. data/exe/lutaml-lml-lsp +11 -0
  8. data/lib/compat/opal/generate_boot.rb +12 -5
  9. data/lib/compat/opal/lutaml_model_boot.rb +96 -4
  10. data/lib/lutaml/lml/association_label_resolver.rb +52 -0
  11. data/lib/lutaml/lml/data_processor/attribute_processing.rb +133 -0
  12. data/lib/lutaml/lml/data_processor/collection_processing.rb +37 -0
  13. data/lib/lutaml/lml/data_processor/instance_processing.rb +77 -0
  14. data/lib/lutaml/lml/data_processor/value_declaration_processing.rb +70 -0
  15. data/lib/lutaml/lml/data_processor/value_processing.rb +103 -0
  16. data/lib/lutaml/lml/data_processor/view_processing.rb +26 -0
  17. data/lib/lutaml/lml/data_processor.rb +66 -0
  18. data/lib/lutaml/lml/diagnostic.rb +149 -0
  19. data/lib/lutaml/lml/document_builder.rb +486 -0
  20. data/lib/lutaml/lml/entity_types.rb +31 -0
  21. data/lib/lutaml/lml/executor/adapter_helpers.rb +45 -0
  22. data/lib/lutaml/lml/executor/condition_evaluator.rb +175 -0
  23. data/lib/lutaml/lml/executor/csv_adapter.rb +89 -0
  24. data/lib/lutaml/lml/executor/format_adapter.rb +54 -0
  25. data/lib/lutaml/lml/executor/xml_adapter.rb +102 -0
  26. data/lib/lutaml/lml/executor.rb +96 -0
  27. data/lib/lutaml/lml/format/adapter/document.rb +11 -0
  28. data/lib/lutaml/lml/format/adapter/mapping.rb +31 -0
  29. data/lib/lutaml/lml/format/adapter/standard_adapter.rb +164 -0
  30. data/lib/lutaml/lml/format/adapter/transform.rb +11 -0
  31. data/lib/lutaml/lml/format.rb +34 -0
  32. data/lib/lutaml/lml/formatter/base.rb +81 -0
  33. data/lib/lutaml/lml/formatter/canonical.rb +738 -0
  34. data/lib/lutaml/lml/formatter.rb +11 -0
  35. data/lib/lutaml/lml/grammar/lml.artifact.json +14993 -0
  36. data/lib/lutaml/lml/grammar/lml.parg +389 -0
  37. data/lib/lutaml/lml/grammar.rb +60 -0
  38. data/lib/lutaml/lml/has_attributes.rb +14 -0
  39. data/lib/lutaml/lml/import_resolver.rb +96 -0
  40. data/lib/lutaml/lml/layout/engine.rb +17 -0
  41. data/lib/lutaml/lml/layout.rb +9 -0
  42. data/lib/lutaml/lml/literal_value.rb +32 -0
  43. data/lib/lutaml/lml/lsp/conversions.rb +78 -0
  44. data/lib/lutaml/lml/lsp/keywords.rb +43 -0
  45. data/lib/lutaml/lml/lsp/server.rb +380 -0
  46. data/lib/lutaml/lml/lsp/store.rb +68 -0
  47. data/lib/lutaml/lml/lsp/transport.rb +53 -0
  48. data/lib/lutaml/lml/lsp.rb +16 -0
  49. data/lib/lutaml/lml/model_compiler/enums.rb +170 -0
  50. data/lib/lutaml/lml/model_compiler/hydration.rb +122 -0
  51. data/lib/lutaml/lml/model_compiler/serialization_mappings.rb +188 -0
  52. data/lib/lutaml/lml/model_compiler/string_formats.rb +42 -0
  53. data/lib/lutaml/lml/model_compiler/validation.rb +65 -0
  54. data/lib/lutaml/lml/model_compiler.rb +329 -0
  55. data/lib/lutaml/lml/models/action.rb +10 -0
  56. data/lib/lutaml/lml/models/association.rb +31 -0
  57. data/lib/lutaml/lml/models/cardinality.rb +10 -0
  58. data/lib/lutaml/lml/models/collection.rb +11 -0
  59. data/lib/lutaml/lml/models/constraint.rb +25 -0
  60. data/lib/lutaml/lml/models/data_type.rb +43 -0
  61. data/lib/lutaml/lml/models/derived_field.rb +14 -0
  62. data/lib/lutaml/lml/models/diagram.rb +22 -0
  63. data/lib/lutaml/lml/models/document.rb +86 -0
  64. data/lib/lutaml/lml/models/enum.rb +40 -0
  65. data/lib/lutaml/lml/models/fidelity.rb +10 -0
  66. data/lib/lutaml/lml/models/group.rb +11 -0
  67. data/lib/lutaml/lml/models/instance.rb +28 -0
  68. data/lib/lutaml/lml/models/instance_collection.rb +18 -0
  69. data/lib/lutaml/lml/models/instances_export.rb +10 -0
  70. data/lib/lutaml/lml/models/instances_import.rb +11 -0
  71. data/lib/lutaml/lml/models/mapping.rb +15 -0
  72. data/lib/lutaml/lml/models/mapping_rule.rb +16 -0
  73. data/lib/lutaml/lml/models/member_field.rb +16 -0
  74. data/lib/lutaml/lml/models/namespace.rb +18 -0
  75. data/lib/lutaml/lml/models/operation.rb +28 -0
  76. data/lib/lutaml/lml/models/operation_parameter.rb +12 -0
  77. data/lib/lutaml/lml/models/package.rb +28 -0
  78. data/lib/lutaml/lml/models/primitive_type.rb +35 -0
  79. data/lib/lutaml/lml/models/reference.rb +23 -0
  80. data/lib/lutaml/lml/models/serialization_mapping.rb +21 -0
  81. data/lib/lutaml/lml/models/string_format.rb +16 -0
  82. data/lib/lutaml/lml/models/top_element_attribute.rb +118 -0
  83. data/lib/lutaml/lml/models/uml_class.rb +87 -0
  84. data/lib/lutaml/lml/models/value.rb +17 -0
  85. data/lib/lutaml/lml/models/view_filter.rb +11 -0
  86. data/lib/lutaml/lml/models/view_import.rb +11 -0
  87. data/lib/lutaml/lml/parser.rb +19 -0
  88. data/lib/lutaml/lml/pipeline.rb +73 -0
  89. data/lib/lutaml/lml/positioned.rb +13 -0
  90. data/lib/lutaml/lml/preprocessor.rb +132 -0
  91. data/lib/lutaml/lml/quoting.rb +60 -0
  92. data/lib/lutaml/lml/source.rb +49 -0
  93. data/lib/lutaml/lml/source_position.rb +20 -0
  94. data/lib/lutaml/lml/symbol_index.rb +202 -0
  95. data/lib/lutaml/lml/transform.rb +119 -0
  96. data/lib/lutaml/lml/types/text_type.rb +28 -0
  97. data/lib/lutaml/lml/types.rb +10 -0
  98. data/lib/lutaml/lml/validator.rb +460 -0
  99. data/lib/lutaml/lml/view_resolution.rb +32 -0
  100. data/lib/lutaml/lml/view_resolver.rb +48 -0
  101. data/lib/lutaml/lml/yaml_parser.rb +17 -0
  102. data/lib/lutaml/lml.rb +130 -0
  103. data/lib/lutaml/model/adapter_resolver.rb +21 -2
  104. data/lib/lutaml/model/config.rb +22 -0
  105. data/lib/lutaml/model/serialize/format_conversion.rb +8 -6
  106. data/lib/lutaml/model/version.rb +1 -1
  107. data/lib/lutaml/xml/adapter/base_adapter.rb +26 -0
  108. data/lib/lutaml/xml/adapter/moxml_adapter.rb +49 -0
  109. data/lib/lutaml/xml/adapter/xml_parser.rb +4 -4
  110. data/lib/lutaml/xml/adapter/xml_serializer.rb +1 -1
  111. data/lib/lutaml/xml/adapter.rb +5 -0
  112. data/lib/lutaml/xml/adapter_loader.rb +5 -0
  113. data/lib/lutaml/xml/format.rb +23 -2
  114. data/lib/lutaml/xml/leptris/native_emission.rb +6 -1
  115. data/lib/lutaml/xml/leptris/plan_serializer.rb +5 -1
  116. data/lib/lutaml/xml/parse_session.rb +8 -1
  117. data/lib/lutaml/xml/schema/builder/moxml.rb +1 -1
  118. data/lib/lutaml/xml/schema/builder.rb +1 -1
  119. data/lib/lutaml/xml/schema/relaxng_schema.rb +1 -1
  120. data/lib/lutaml/xml/schema/vc_namespace.rb +24 -0
  121. data/lib/lutaml/xml/schema/xsd/any.rb +4 -0
  122. data/lib/lutaml/xml/schema/xsd/any_attribute.rb +4 -0
  123. data/lib/lutaml/xml/schema/xsd/base.rb +7 -0
  124. data/lib/lutaml/xml/schema/xsd/open_content.rb +2 -0
  125. data/lib/lutaml/xml/schema/xsd/restriction_simple_type.rb +3 -0
  126. data/lib/lutaml/xml/schema/xsd/schema.rb +38 -0
  127. data/lib/lutaml/xml/schema/xsd/schema_validator.rb +1 -1
  128. data/lib/lutaml/xml/schema/xsd.rb +1 -0
  129. data/lib/lutaml/xml/schema/xsd_schema.rb +1 -1
  130. data/lib/lutaml/xml/serialization/format_conversion.rb +6 -0
  131. data/lib/lutaml/xml/xsd_validator.rb +1 -1
  132. data/lutaml-model.gemspec +2 -0
  133. data/spec/lml/fixtures/dsl/broken_diagram.lutaml +34 -0
  134. data/spec/lml/fixtures/dsl/diagram.lutaml +4 -0
  135. data/spec/lml/fixtures/dsl/diagram_attributes.lutaml +6 -0
  136. data/spec/lml/fixtures/dsl/diagram_blank_definion.lutaml +6 -0
  137. data/spec/lml/fixtures/dsl/diagram_blank_entities.lutaml +8 -0
  138. data/spec/lml/fixtures/dsl/diagram_class_assocation.lutaml +29 -0
  139. data/spec/lml/fixtures/dsl/diagram_class_fields.lutaml +25 -0
  140. data/spec/lml/fixtures/dsl/diagram_commented_includes.lutaml +5 -0
  141. data/spec/lml/fixtures/dsl/diagram_comments.lutaml +28 -0
  142. data/spec/lml/fixtures/dsl/diagram_concept_model.lutaml +132 -0
  143. data/spec/lml/fixtures/dsl/diagram_data_types.lutaml +44 -0
  144. data/spec/lml/fixtures/dsl/diagram_definitions.lutaml +25 -0
  145. data/spec/lml/fixtures/dsl/diagram_includes.lutaml +6 -0
  146. data/spec/lml/fixtures/dsl/diagram_multiply_classes.lutaml +7 -0
  147. data/spec/lml/fixtures/dsl/diagram_non_existing_include.lutaml +6 -0
  148. data/spec/lml/fixtures/dsl/shared.lutaml +5 -0
  149. data/spec/lml/fixtures/dsl/shared1.lutaml +4 -0
  150. data/spec/lml/fixtures/generated_dot/AddressClassProfile.dot +170 -0
  151. data/spec/lml/fixtures/generated_dot/AddressProfile.dot +34 -0
  152. data/spec/lml/fixtures/generated_dot/address_class_profile_with_associations.dot +127 -0
  153. data/spec/lml/fixtures/generated_dot/address_profile_with_associations.dot +28 -0
  154. data/spec/lml/fixtures/generated_dot/document.dot +28 -0
  155. data/spec/lml/fixtures/generated_dot/document.dot.backup +33 -0
  156. data/spec/lml/fixtures/generated_dot/document_with_fidelity.dot +27 -0
  157. data/spec/lml/fixtures/lml/data_s102_check.lml +79 -0
  158. data/spec/lml/fixtures/lml/data_s158_metadata.lml +28 -0
  159. data/spec/lml/fixtures/lml/iho_data_models.lml +59 -0
  160. data/spec/lml/fixtures/lml/iho_s102_check.lml +101 -0
  161. data/spec/lml/fixtures/mixed_lml/diagram.lml +26 -0
  162. data/spec/lml/fixtures/mixed_lml/instances.lml +72 -0
  163. data/spec/lml/fixtures/mixed_lml/model.lml +30 -0
  164. data/spec/lml/fixtures/real_world/basicdoc-models/AdmonitionType.lutaml +32 -0
  165. data/spec/lml/fixtures/real_world/basicdoc-models/BasicBlock.lutaml +11 -0
  166. data/spec/lml/fixtures/real_world/basicdoc-models/BasicDocument.lutaml +41 -0
  167. data/spec/lml/fixtures/real_world/basicdoc-models/BasicSection.lutaml +38 -0
  168. data/spec/lml/fixtures/real_world/basicdoc-models/BibliographicItem.lutaml +6 -0
  169. data/spec/lml/fixtures/real_world/basicdoc-models/FigureBlock.lutaml +65 -0
  170. data/spec/lml/fixtures/real_world/basicdoc-models/FormattedString.lutaml +12 -0
  171. data/spec/lml/fixtures/real_world/basicdoc-models/List.lutaml +12 -0
  172. data/spec/lml/fixtures/real_world/basicdoc-models/OrderedListType.lutaml +32 -0
  173. data/spec/lml/fixtures/real_world/basicdoc-models/Signature.lutaml +22 -0
  174. data/spec/lml/fixtures/real_world/basicdoc-models/String.lutaml +2 -0
  175. data/spec/lml/fixtures/real_world/basicdoc-models/TableBlock.lutaml +60 -0
  176. data/spec/lml/fixtures/real_world/basicdoc-models/TextElement.lutaml +13 -0
  177. data/spec/lml/fixtures/real_world/basicdoc-models/Uri.lutaml +7 -0
  178. data/spec/lml/fixtures/real_world/metanorma-model-iso/BibliographicItem.lutaml +4 -0
  179. data/spec/lml/fixtures/real_world/metanorma-model-iso/IsoAdmonitionType.lutaml +31 -0
  180. data/spec/lml/fixtures/real_world/metanorma-model-iso/IsoBibDataExtensionType.lutaml +40 -0
  181. data/spec/lml/fixtures/real_world/metanorma-model-iso/IsoSections.lutaml +30 -0
  182. data/spec/lml/fixtures/real_world/metanorma-model-iso/IsoStandardDocument.lutaml +46 -0
  183. data/spec/lml/fixtures/real_world/metanorma-model-iso/IsoTerm.lutaml +20 -0
  184. data/spec/lml/fixtures/real_world/metanorma-model-iso/StandardBibDataExtensionType.lutaml +2 -0
  185. data/spec/lml/fixtures/real_world/metanorma-model-iso/StandardDocument.lutaml +2 -0
  186. data/spec/lml/fixtures/rs3001/01_class_tail_comment.lml +5 -0
  187. data/spec/lml/fixtures/rs3001/02_definition_block.lml +9 -0
  188. data/spec/lml/fixtures/rs3001/03_package_ceramics.lml +20 -0
  189. data/spec/lml/fixtures/rs3001/04_attribute_definition_form.lml +10 -0
  190. data/spec/lml/fixtures/rs3001/05_attribute_cardinality_unbounded.lml +10 -0
  191. data/spec/lml/fixtures/rs3001/06_attribute_values_set.lml +10 -0
  192. data/spec/lml/fixtures/rs3001/07_attribute_pattern.lml +10 -0
  193. data/spec/lml/fixtures/rs3001/08_attribute_default_colon.lml +15 -0
  194. data/spec/lml/fixtures/rs3001/09_value_porcelain.lml +9 -0
  195. data/spec/lml/fixtures/rs3001/10_enum_glaze_technique.lml +19 -0
  196. data/spec/lml/fixtures/rs3001/11_enum_values_as_instances.lml +29 -0
  197. data/spec/lml/fixtures/rs3001/12_instance_named.lml +13 -0
  198. data/spec/lml/fixtures/rs3001/13_instances_collection_refs.lml +11 -0
  199. data/spec/lml/fixtures/rs3001/14_require_models.lml +7 -0
  200. data/spec/lml/fixtures/rs3001/15_comment_line.lml +1 -0
  201. data/spec/lml/fixtures/rs3001/16_comment_tail.lml +5 -0
  202. data/spec/lml/fixtures/rs3001/17_comment_documented_class.lml +5 -0
  203. data/spec/lml/fixtures/rs3001/18_comment_block.lml +4 -0
  204. data/spec/lml/fixtures/rs3001/19_top_level_instance_definition.lml +21 -0
  205. data/spec/lml/fixtures/rs3001/20_instance_typed_definition.lml +22 -0
  206. data/spec/lml/fixtures/rs3001/21_instance_collection_studios.lml +19 -0
  207. data/spec/lml/fixtures/rs3001/22_instance_collection_tiles.lml +15 -0
  208. data/spec/lml/fixtures/rs3001/23_reference_cross_collection.lml +11 -0
  209. data/spec/lml/fixtures/rs3001/24_null_and_empty.lml +15 -0
  210. data/spec/lml/fixtures/rs3001/25_string_escapes.lml +23 -0
  211. data/spec/lml/fixtures/rs3001/26_quoted_keys.lml +7 -0
  212. data/spec/lml/fixtures/test.lutaml +20 -0
  213. data/spec/lml/fixtures/test_data/components.csv +4 -0
  214. data/spec/lml/fixtures/test_data/products.xml +18 -0
  215. data/spec/lml/fixtures/uml/address_class_profile_with_associations.yml +58 -0
  216. data/spec/lml/fixtures/uml/address_profile_with_associations.yml +31 -0
  217. data/spec/lml/fixtures/uml/association.yml +11 -0
  218. data/spec/lml/fixtures/uml/class.yml +28 -0
  219. data/spec/lml/fixtures/uml/data_type.yml +30 -0
  220. data/spec/lml/fixtures/uml/diagram.yml +7 -0
  221. data/spec/lml/fixtures/uml/document.yml +44 -0
  222. data/spec/lml/fixtures/uml/document_with_fidelity.yml +47 -0
  223. data/spec/lml/fixtures/uml/enum.yml +14 -0
  224. data/spec/lml/fixtures/uml/operation.yml +8 -0
  225. data/spec/lml/fixtures/uml/package.yml +10 -0
  226. data/spec/lml/fixtures/uml/top_element.yml +11 -0
  227. data/spec/lml/fixtures/uml/top_element_attribute.yml +10 -0
  228. data/spec/lml/fixtures/uml/trigger.yml +12 -0
  229. data/spec/lml/fixtures/uml/value.yml +8 -0
  230. data/spec/lml/fixtures/view/cycle_a.lutaml +3 -0
  231. data/spec/lml/fixtures/view/cycle_b.lutaml +3 -0
  232. data/spec/lml/fixtures/view/import_model.lutaml +3 -0
  233. data/spec/lml/fixtures/view/import_view.lutaml +3 -0
  234. data/spec/lml/fixtures/view/import_with_hide.lutaml +4 -0
  235. data/spec/lml/fixtures/view/import_with_show.lutaml +4 -0
  236. data/spec/lml/fixtures/view/models/bar.lutaml +3 -0
  237. data/spec/lml/fixtures/view/models/baz.lutaml +3 -0
  238. data/spec/lml/fixtures/view/models/foo.lutaml +4 -0
  239. data/spec/lml/integration/instance_import_export_spec.rb +102 -0
  240. data/spec/lml/lml_spec_setup.rb +25 -0
  241. data/spec/lml/lutaml/lml/association_label_resolver_spec.rb +139 -0
  242. data/spec/lml/lutaml/lml/data_processor_spec.rb +274 -0
  243. data/spec/lml/lutaml/lml/declarations_spec.rb +337 -0
  244. data/spec/lml/lutaml/lml/document_builder_registry_spec.rb +52 -0
  245. data/spec/lml/lutaml/lml/document_builder_spec.rb +99 -0
  246. data/spec/lml/lutaml/lml/element_visibility_spec.rb +128 -0
  247. data/spec/lml/lutaml/lml/entity_types_spec.rb +56 -0
  248. data/spec/lml/lutaml/lml/enum_spec.rb +77 -0
  249. data/spec/lml/lutaml/lml/executor/adapter_helpers_spec.rb +96 -0
  250. data/spec/lml/lutaml/lml/executor/condition_evaluator_spec.rb +393 -0
  251. data/spec/lml/lutaml/lml/executor/csv_adapter_spec.rb +151 -0
  252. data/spec/lml/lutaml/lml/executor/format_adapter_spec.rb +31 -0
  253. data/spec/lml/lutaml/lml/executor/xml_adapter_spec.rb +201 -0
  254. data/spec/lml/lutaml/lml/executor_spec.rb +71 -0
  255. data/spec/lml/lutaml/lml/format_adapter_spec.rb +272 -0
  256. data/spec/lml/lutaml/lml/format_autoload_spec.rb +31 -0
  257. data/spec/lml/lutaml/lml/grammar_spec.rb +581 -0
  258. data/spec/lml/lutaml/lml/has_attributes_spec.rb +54 -0
  259. data/spec/lml/lutaml/lml/import_resolver_spec.rb +116 -0
  260. data/spec/lml/lutaml/lml/instance_hydration_spec.rb +178 -0
  261. data/spec/lml/lutaml/lml/lsp/server_spec.rb +285 -0
  262. data/spec/lml/lutaml/lml/model_compiler_spec.rb +406 -0
  263. data/spec/lml/lutaml/lml/models/association_spec.rb +40 -0
  264. data/spec/lml/lutaml/lml/models/collection_spec.rb +27 -0
  265. data/spec/lml/lutaml/lml/models/data_type_spec.rb +34 -0
  266. data/spec/lml/lutaml/lml/models/diagram_spec.rb +18 -0
  267. data/spec/lml/lutaml/lml/models/document_spec.rb +64 -0
  268. data/spec/lml/lutaml/lml/models/enum_spec.rb +42 -0
  269. data/spec/lml/lutaml/lml/models/inheritance_spec.rb +77 -0
  270. data/spec/lml/lutaml/lml/models/instance_collection_spec.rb +62 -0
  271. data/spec/lml/lutaml/lml/models/instance_spec.rb +81 -0
  272. data/spec/lml/lutaml/lml/models/instances_export_spec.rb +23 -0
  273. data/spec/lml/lutaml/lml/models/instances_import_spec.rb +28 -0
  274. data/spec/lml/lutaml/lml/models/package_spec.rb +26 -0
  275. data/spec/lml/lutaml/lml/models/primitive_type_spec.rb +34 -0
  276. data/spec/lml/lutaml/lml/models/top_element_attribute_spec.rb +153 -0
  277. data/spec/lml/lutaml/lml/models/uml_class_spec.rb +70 -0
  278. data/spec/lml/lutaml/lml/models_version_spec.rb +27 -0
  279. data/spec/lml/lutaml/lml/operations_spec.rb +59 -0
  280. data/spec/lml/lutaml/lml/parser_spec.rb +348 -0
  281. data/spec/lml/lutaml/lml/pipeline_spec.rb +93 -0
  282. data/spec/lml/lutaml/lml/preprocessor_spec.rb +174 -0
  283. data/spec/lml/lutaml/lml/property_laws_spec.rb +344 -0
  284. data/spec/lml/lutaml/lml/real_world_spec.rb +191 -0
  285. data/spec/lml/lutaml/lml/reference_spec.rb +64 -0
  286. data/spec/lml/lutaml/lml/round_trip_spec.rb +457 -0
  287. data/spec/lml/lutaml/lml/rs3001_corpus_spec.rb +83 -0
  288. data/spec/lml/lutaml/lml/rs3001_syntax_spec.rb +77 -0
  289. data/spec/lml/lutaml/lml/serialization_mapping_spec.rb +127 -0
  290. data/spec/lml/lutaml/lml/source_spec.rb +62 -0
  291. data/spec/lml/lutaml/lml/transform_spec.rb +37 -0
  292. data/spec/lml/lutaml/lml/types/text_type_spec.rb +43 -0
  293. data/spec/lml/lutaml/lml/validator_spec.rb +238 -0
  294. data/spec/lml/lutaml/lml/view_resolver_spec.rb +78 -0
  295. data/spec/lml/lutaml/lml/view_spec.rb +112 -0
  296. data/spec/lml/lutaml/parsers/dsl_spec.rb +275 -0
  297. data/spec/lml/lutaml/parsers/yaml_spec.rb +52 -0
  298. data/spec/lml/lutaml/qualified_type_spec.rb +33 -0
  299. data/spec/lutaml/model/adapter_type_unset_restore_spec.rb +61 -0
  300. data/spec/lutaml/model/custom_bibtex_adapter_spec.rb +4 -1
  301. data/spec/lutaml/xml/adapter/moxml_lane_spec.rb +112 -0
  302. data/spec/lutaml/xml/adapter_metadata_default_spec.rb +21 -2
  303. data/spec/lutaml/xml/adapter_moxml_engine_spec.rb +57 -0
  304. data/spec/lutaml/xml/leptris/native_emission_plain_model_spec.rb +50 -0
  305. data/spec/lutaml/xml/plain_model_mapping_resolution_spec.rb +88 -0
  306. data/spec/lutaml/xml/schema/xsd/vc_versioning_spec.rb +49 -0
  307. data/spec/lutaml/xml/schema/xsd/xsd_11_constructs_spec.rb +83 -0
  308. metadata +286 -2
@@ -0,0 +1,170 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Lutaml
4
+ module Lml
5
+ class ModelCompiler
6
+ # Compiles LML enums into Serializable subclasses with member
7
+ # payloads, table-driven expansion, and value accessors.
8
+ module Enums
9
+ EnumValue = Struct.new(:name, :description, :payload)
10
+
11
+ # The member description rides a nested attribute named `description`
12
+ # (bare-member form) or `definition` (RS 3001 `value` blocks); both
13
+ # spellings are accepted.
14
+ MEMBER_DESCRIPTION_NAMES = %w[description definition].freeze
15
+
16
+ private
17
+
18
+ def compile_enum(enum_def)
19
+ name = enum_def.name.to_s
20
+ expand_from_table(enum_def)
21
+ values = extract_enum_values(enum_def)
22
+
23
+ payload_fields = Array(enum_def.member_fields).map { |f| f.name.to_s }
24
+ value_names = values.map { |v| v.name.to_s }
25
+ compiled_klass = Class.new(Lutaml::Model::Serializable) do
26
+ attribute :value, :string, values: value_names, default: values.first.name
27
+ attribute :description, :string
28
+ payload_fields.each do |field|
29
+ attribute field.to_sym, :string
30
+ end
31
+
32
+ define_method(:to_s) { value }
33
+ end
34
+
35
+ values.each do |value|
36
+ accessor = value.name.to_s.gsub(/[^a-zA-Z0-9_]/, "_")
37
+ compiled_klass.define_singleton_method(accessor) do
38
+ new({ value: value.name, description: value.description }.merge(value.payload || {}))
39
+ end
40
+ end
41
+ compiled_klass.define_singleton_method(:values) { values }
42
+
43
+ @enum_names << name
44
+ @enum_classes[name] = compiled_klass
45
+ register(name, compiled_klass)
46
+ end
47
+
48
+ # Builds a compiled Serializable subclass from a class or data-type
49
+ # definition: declares attributes and stashes forward-referenced
50
+ # attributes for post-registration resolution.
51
+
52
+ # RS 3001 §Attribute: `values { v1, v2 }` expands into an anonymous
53
+ # enum baked from the inline set; the attribute is typed with it.
54
+ def resolve_values_type(klass_def, attr)
55
+ return attr.type.to_s unless attr.value_set&.any?
56
+
57
+ enum_name = anonymous_enum_name(klass_def.name, attr.name)
58
+ members = attr.value_set.map { |v| ::Lutaml::Lml::TopElementAttribute.new(name: v.to_s) }
59
+ compile_enum(::Lutaml::Lml::Enum.new(name: enum_name, attributes: members))
60
+ enum_name
61
+ end
62
+
63
+ def anonymous_enum_name(class_name, attr_name)
64
+ base = class_name.to_s.split("::").last
65
+ attr_part = attr_name.to_s.split("_").map(&:capitalize).join
66
+ "#{base}#{attr_part}Values"
67
+ end
68
+
69
+ # L7a point 3: from_table members are baked at compile time — the
70
+ # artifact table's rows become the values, validated against the
71
+ # declared member_fields (unknown field = error; missing = nil).
72
+ # The member name comes from the row's "name" column.
73
+ def expand_from_table(enum_def)
74
+ return unless enum_def.from_table_name
75
+
76
+ rows = artifact_table_rows(enum_def)
77
+ known = Array(enum_def.member_fields).map { |f| f.name.to_s }
78
+ rows.each do |row|
79
+ row = row.transform_keys(&:to_s)
80
+ member_name = row.fetch("name")
81
+ unknown = row.keys - known - ["name"]
82
+ if unknown.any?
83
+ raise ArgumentError,
84
+ "enum #{enum_def.name}: table row #{member_name.inspect} has " \
85
+ "undeclared fields #{unknown.inspect} (declared: #{known.inspect})"
86
+ end
87
+ payload = row.slice(*known).compact
88
+ enum_def.attributes << TopElementAttribute.new(
89
+ name: member_name,
90
+ properties: payload.map do |field, value|
91
+ TopElementAttribute.new(name: field, value: value)
92
+ end,
93
+ )
94
+ end
95
+ end
96
+
97
+ def artifact_table_rows(enum_def)
98
+ reference = enum_def.from_table_artifact || @default_artifact
99
+ path = artifact_path_for(reference.to_s)
100
+ unless path
101
+ raise ArgumentError,
102
+ "enum #{enum_def.name}: from_table artifact #{reference.inspect} not found"
103
+ end
104
+
105
+ envelope = JSON.parse(File.read(path))
106
+ table = envelope["tables"].to_h[enum_def.from_table_name]
107
+ unless table
108
+ raise ArgumentError,
109
+ "enum #{enum_def.name}: table #{enum_def.from_table_name.inspect} " \
110
+ "not found in artifact #{reference.inspect}"
111
+ end
112
+
113
+ table["rows"].to_a
114
+ end
115
+
116
+ def extract_enum_values(enum_def)
117
+ member_fields = Array(enum_def.member_fields).map do |f|
118
+ [f.name.to_s, f.type.to_s]
119
+ end
120
+ enum_def.attributes.map do |attr|
121
+ description = member_description(attr)
122
+ payload = extract_member_payload(attr)
123
+ validate_member_payload(enum_def, attr, payload, member_fields)
124
+ EnumValue.new(attr.name.to_s, description, payload)
125
+ end
126
+ end
127
+
128
+ def member_description(attr)
129
+ nested = Array(attr.attributes).find do |n|
130
+ MEMBER_DESCRIPTION_NAMES.include?(n.name.to_s)
131
+ end
132
+ text = nested&.type || nested&.definition || nested&.value
133
+ text.is_a?(Hash) && text.key?(:string) ? text[:string] : text
134
+ end
135
+
136
+ # L7a: per-member payload lines ride the keyword-attribute
137
+ # properties (`abbreviation = "WD"`)
138
+
139
+ # L7a: per-member payload lines ride the keyword-attribute
140
+ # properties (`abbreviation = "WD"`)
141
+ def extract_member_payload(attr)
142
+ Array(attr.properties).to_h { |p| [p.name.to_s, p.value&.to_s] }
143
+ end
144
+
145
+ def validate_member_payload(enum_def, attr, payload, member_fields)
146
+ known = member_fields.map(&:first)
147
+ unknown = payload.keys - known
148
+ return unless unknown.any?
149
+
150
+ raise ArgumentError,
151
+ "enum #{enum_def.name}: member #{attr.name} has undeclared " \
152
+ "payload fields #{unknown.inspect} (declared: #{known.inspect})"
153
+ end
154
+
155
+ def enum_class_for(type)
156
+ type.is_a?(Class) && @enum_classes.value?(type) and return type
157
+ end
158
+
159
+ def enum_value_name(raw)
160
+ raw.split("::").last
161
+ end
162
+
163
+ # L7b: derived fields declare existence + type; computation is
164
+ # bound by the binder from artifact derive specs. The attribute
165
+ # participates in mappings like any other (relaton consumes URNs
166
+ # from model JSON).
167
+ end
168
+ end
169
+ end
170
+ end
@@ -0,0 +1,122 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Lutaml
4
+ module Lml
5
+ class ModelCompiler
6
+ # Builds typed instances from parsed instance documents
7
+ # against the compiled class set.
8
+ module Hydration
9
+ private
10
+
11
+ def hydrate_instance(instance)
12
+ inner = instance.instance
13
+ return hydrate_instance(inner) if inner && Array(instance.attributes).empty?
14
+
15
+ type_name = resolve_instance_type(instance)
16
+ klass = @compiled[type_name]
17
+ return hydrate_as_untyped(instance, type_name) unless klass
18
+
19
+ attrs = extract_instance_attributes(instance, klass)
20
+ klass.new(**attrs)
21
+ end
22
+
23
+ # An inline map's cargo is {key_value_map: [{key:, value:}, ...]} with
24
+ # literal-shaped keys/values ({string: ..}, {number: ..}, {boolean: ..});
25
+ # materialize it as a plain Hash (issue #17: maps hydrate as data).
26
+
27
+ # An inline map's cargo is {key_value_map: [{key:, value:}, ...]} with
28
+ # literal-shaped keys/values ({string: ..}, {number: ..}, {boolean: ..});
29
+ # materialize it as a plain Hash (issue #17: maps hydrate as data).
30
+ def hydrate_map_cargo(cargo)
31
+ cargo[:key_value_map].to_h do |pair|
32
+ [hydrate_scalar(pair[:key]).to_s, hydrate_scalar(pair[:value])]
33
+ end
34
+ end
35
+
36
+ def hydrate_scalar(literal)
37
+ literal = literal.value if literal.respond_to?(:value)
38
+ literal.is_a?(Hash) ? literal.values.first : literal
39
+ end
40
+
41
+ def resolve_instance_type(instance)
42
+ # L6: the explicit isa keyword is the type override; a `type`
43
+ # attribute is ordinary data (pubid's identifier-kind field)
44
+ return demodulize(instance.isa.to_s) if instance.isa
45
+
46
+ demodulize(instance.type.to_s)
47
+ end
48
+
49
+ def demodulize(name)
50
+ name.split("::").last.to_s
51
+ end
52
+
53
+ def hydrate_as_untyped(instance, type_name)
54
+ { _name: type_name, **extract_raw_attributes(instance) }
55
+ end
56
+
57
+ def extract_raw_attributes(instance)
58
+ instance.each_attribute.with_object({}) do |(name, value, nested), hash|
59
+ hash[name.to_sym] = resolve_instance_value(value, nested)
60
+ end
61
+ end
62
+
63
+ def extract_instance_attributes(instance, klass)
64
+ schema_keys = klass.attributes.keys.to_set
65
+ instance.each_attribute.with_object({}) do |(name, value, nested), hash|
66
+ key = name.to_sym
67
+ next unless schema_keys.include?(key)
68
+
69
+ hash[key] = resolve_instance_value(value, nested, klass.attributes[key])
70
+ end
71
+ end
72
+
73
+ def resolve_instance_value(value, nested, attr_def = nil)
74
+ value = value.value if value.respond_to?(:value)
75
+ return hydrate_map_cargo(value) if value.is_a?(Hash) && value.key?(:key_value_map)
76
+
77
+ if nested.any?
78
+ # A scalar attribute with a single nested instance hydrates to
79
+ # the object itself; the declaration is the truth (issue #17).
80
+ return hydrate_typed(nested.first, attr_def) if !attr_def&.collection && nested.one?
81
+
82
+ nested.map { |i| hydrate_typed(i, attr_def) }
83
+ # The Array guard must run before the enum branch: an array
84
+ # value under an enum-typed attribute stays a raw array.
85
+ # rubocop:disable-next Lint/DuplicateBranch
86
+ elsif value.is_a?(Array)
87
+ value
88
+ elsif (enum_class = attr_def && enum_class_for(attr_def.type))
89
+ value_name = enum_value_name(value.to_s)
90
+ description = enum_class.values
91
+ .find { |v| v.name == value_name }&.description
92
+ enum_class.new(value: value_name, description: description)
93
+ elsif !value.nil?
94
+ value
95
+ end
96
+ end
97
+
98
+ # An untyped nested instance takes the enclosing attribute's type;
99
+ # hydrate_as_untyped would otherwise emit a raw hash polluted with
100
+ # a `_name` key, which also defeats union member key-coverage.
101
+
102
+ # An untyped nested instance takes the enclosing attribute's type;
103
+ # hydrate_as_untyped would otherwise emit a raw hash polluted with
104
+ # a `_name` key, which also defeats union member key-coverage.
105
+ def hydrate_typed(instance, attr_def)
106
+ return hydrate_instance(instance) if instance.isa || !instance.type.to_s.empty?
107
+
108
+ type = attr_def&.type
109
+ return hydrate_instance(instance) unless type.is_a?(Class)
110
+
111
+ if type.include?(Lutaml::Model::Serialize)
112
+ type.new(**extract_instance_attributes(instance, type))
113
+ elsif type == Lutaml::Model::Type::Union
114
+ extract_raw_attributes(instance)
115
+ else
116
+ hydrate_instance(instance)
117
+ end
118
+ end
119
+ end
120
+ end
121
+ end
122
+ end
@@ -0,0 +1,188 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Lutaml
4
+ module Lml
5
+ class ModelCompiler
6
+ # Applies declared LML serialization mappings
7
+ # (xml / key_value wire names, namespaces) onto compiled classes.
8
+ module SerializationMappings
9
+ private
10
+
11
+ # In-class `mapping <format> { … }` is the shortcut for a sibling
12
+ # mapping targeting the enclosing class; hoist them so emission is
13
+ # uniform.
14
+ def hoist_class_serialization_mappings(doc)
15
+ (Array(doc.classes) + Array(doc.data_types)).each do |klass_def|
16
+ Array(klass_def.serialization_mappings).each do |mapping|
17
+ mapping.target = klass_def.name.to_s
18
+ @serialization_mappings << mapping
19
+ end
20
+ end
21
+ end
22
+
23
+ # Emit the lutaml-model mapping blocks declared in the LML source:
24
+ # mapping yaml { map "full-name", to: "name" }
25
+ # becomes klass.yml do |m| m.map "full-name", to: :name end
26
+ def apply_declared_mappings(compiled_klass, def_obj)
27
+ return unless def_obj.is_a?(UmlClass) || def_obj.is_a?(DataType)
28
+
29
+ def_obj.wire_mappings.to_a.group_by(&:format).each do |format, entries|
30
+ next unless format && Lutaml::Model::FormatRegistry.registered?(format.to_sym)
31
+
32
+ compiled_klass.public_send(format) do |mapping|
33
+ entries.each { |entry| mapping.map(entry.wire, to: entry.to.to_sym) }
34
+ end
35
+ end
36
+ end
37
+
38
+ # Apply a lutaml-model XML mapping to each compiled class so they
39
+ # support from_xml/to_xml. Runs after forward references are resolved
40
+ # so all attributes (immediate + deferred) get element mappings.
41
+ def apply_xml_mappings
42
+ @compiled.each do |name, klass|
43
+ next if @enum_names.include?(name)
44
+
45
+ custom = serialization_mapping_for(name, "xml")
46
+ next apply_custom_xml_mapping(klass, custom) if custom
47
+
48
+ apply_xml_mapping(klass, name)
49
+ end
50
+ end
51
+
52
+ # Default XML mapping: every attribute an element, except those
53
+ # declared `as :attribute`; an in-class `namespace "uri"` becomes
54
+ # the class's XML namespace (issue #49).
55
+ def apply_xml_mapping(klass, root_name)
56
+ attr_names = klass.attributes.keys
57
+ def_obj = @class_defs[root_name]
58
+ roles = xml_roles_of(def_obj)
59
+ ns_class = inline_namespace_class(def_obj)
60
+ klass.xml do |mapping|
61
+ mapping.element(root_name)
62
+ mapping.namespace(ns_class) if ns_class
63
+ attr_names.each do |attr_name|
64
+ if roles[attr_name] == "attribute"
65
+ mapping.map_attribute(attr_name.to_s, to: attr_name)
66
+ else
67
+ mapping.map_element(attr_name.to_s, to: attr_name)
68
+ end
69
+ end
70
+ end
71
+ end
72
+
73
+ def xml_roles_of(def_obj)
74
+ Array(def_obj&.attributes).each_with_object({}) do |attr, roles|
75
+ roles[attr.name.to_sym] = attr.xml_role if attr.xml_role
76
+ end
77
+ end
78
+
79
+ def inline_namespace_class(def_obj)
80
+ decl = def_obj.xml_namespace if def_obj.is_a?(UmlClass)
81
+ return nil unless decl&.uri
82
+
83
+ build_namespace_class("#{decl.uri}|#{decl.prefix}", decl.uri, decl.prefix.to_s)
84
+ end
85
+
86
+ # RS 3010 extension: key-value mapping blocks for the declared
87
+ # formats (yaml/json/toml share lutaml-model's key_value model).
88
+
89
+ # RS 3010 extension: key-value mapping blocks for the declared
90
+ # formats (yaml/json/toml share lutaml-model's key_value model).
91
+ def apply_key_value_mappings
92
+ @compiled.each do |name, klass|
93
+ next if @enum_names.include?(name)
94
+
95
+ custom = serialization_mapping_for(name, "key_value")
96
+ apply_custom_key_value_mapping(klass, custom) if custom
97
+ end
98
+ end
99
+
100
+ def serialization_mapping_for(target, format)
101
+ @serialization_mappings.find do |m|
102
+ m.target.to_s == target && serialization_format(m.format) == format
103
+ end
104
+ end
105
+
106
+ def serialization_format(format)
107
+ %w[yaml json toml].include?(format.to_s) ? "key_value" : format.to_s
108
+ end
109
+
110
+ def apply_custom_xml_mapping(klass, mapping)
111
+ check_namespace_ambiguity(mapping)
112
+ ns_class = namespace_class_for(mapping.namespace_ref) if mapping.namespace_ref
113
+ rule_ns = mapping.rules.select { |r| r.kind == "namespace" }
114
+ .to_h { |r| [r.field, namespace_class_for(r.field)] }
115
+ klass.xml do |m|
116
+ m.element(mapping.element_name) if mapping.element_name
117
+ m.namespace(ns_class) if ns_class
118
+ m.mixed_content if mapping.mixed_content
119
+ mapping.rules.each do |rule|
120
+ case rule.kind
121
+ when "element" then m.map_element(rule.wire, to: rule.field.to_sym)
122
+ when "attribute" then m.map_attribute(rule.wire, to: rule.field.to_sym)
123
+ when "content" then m.map_content(to: rule.field.to_sym)
124
+ when "namespace" then m.namespace(rule_ns[rule.field])
125
+ end
126
+ end
127
+ end
128
+ end
129
+
130
+ def apply_custom_key_value_mapping(klass, mapping)
131
+ formats = mapping.format.to_s == "key_value" ? %w[yaml json toml] : [mapping.format.to_s]
132
+ klass.instance_eval do
133
+ formats.each do |format|
134
+ public_send(format) do |m|
135
+ mapping.rules.each do |rule|
136
+ case rule.kind
137
+ when "map" then m.map(rule.wire, to: rule.field.to_sym)
138
+ when "key" then m.map_key(to_instance: rule.field.to_sym)
139
+ when "value"
140
+ if rule.mode == "as_attribute"
141
+ m.map_value(as_attribute: rule.field.to_sym)
142
+ else
143
+ m.map_value(to_instance: rule.field.to_sym)
144
+ end
145
+ end
146
+ end
147
+ end
148
+ end
149
+ end
150
+ end
151
+
152
+ def check_namespace_ambiguity(mapping)
153
+ return unless mapping.format.to_s == "xml"
154
+ return if mapping.namespace_ref || @declared_namespaces.length < 2
155
+
156
+ raise ArgumentError,
157
+ "mapping #{mapping.format} #{mapping.target}: ambiguous default " \
158
+ "namespace — #{@declared_namespaces.length} namespaces in scope " \
159
+ "(#{@declared_namespaces.map(&:name).join(', ')}); declare one with " \
160
+ "'namespace <name>'"
161
+ end
162
+
163
+ def namespace_class_for(ref)
164
+ return nil if ref.nil?
165
+
166
+ require "lutaml/xml/namespace" unless defined?(Lutaml::Xml::Namespace)
167
+
168
+ ns_class = @namespace_classes[ref]
169
+ return ns_class if ns_class
170
+
171
+ declared = @declared_namespaces.find { |ns| ns.name.to_s == ref }
172
+ raise ArgumentError, "unknown namespace '#{ref}'" unless declared
173
+
174
+ build_namespace_class(ref, declared.uri, declared.prefix.to_s)
175
+ end
176
+
177
+ def build_namespace_class(key, uri, prefix)
178
+ require "lutaml/xml/namespace" unless defined?(Lutaml::Xml::Namespace)
179
+
180
+ @namespace_classes[key] ||= Class.new(Lutaml::Xml::Namespace).tap do |ns_class|
181
+ ns_class.define_singleton_method(:uri) { uri }
182
+ ns_class.define_singleton_method(:prefix_default) { prefix }
183
+ end
184
+ end
185
+ end
186
+ end
187
+ end
188
+ end
@@ -0,0 +1,42 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Lutaml
4
+ module Lml
5
+ class ModelCompiler
6
+ # Registers declared string_format handlers on
7
+ # compiled classes.
8
+ module StringFormats
9
+ private
10
+
11
+ # L5: register grammar-backed string formats. Class-level
12
+ # declarations win; a models-block default applies to classes
13
+ # without their own. Artifact resolution: the compiler's
14
+ # artifacts map (name => path), else the string as a path.
15
+ def register_string_formats(doc)
16
+ defaults = doc.packages.flat_map(&:default_string_formats)
17
+ doc.classes.each do |class_def|
18
+ declared = Array(class_def.string_formats)
19
+ declared.each { |fmt| register_string_format(class_def.name.to_s, fmt) }
20
+
21
+ declared_formats = declared.map(&:format)
22
+ defaults.reject { |fmt| declared_formats.include?(fmt.format) }
23
+ .each { |fmt| register_string_format(class_def.name.to_s, fmt) }
24
+ end
25
+ end
26
+
27
+ def register_string_format(class_name, fmt)
28
+ artifact_path = artifact_path_for(fmt.artifact.to_s)
29
+ return unless artifact_path
30
+
31
+ compiled = @compiled[class_name]
32
+ return unless compiled
33
+
34
+ Parsanol::PARG::Lutaml.register(compiled,
35
+ format_name: fmt.format.to_sym,
36
+ artifact: artifact_path,
37
+ entry: fmt.root.to_s)
38
+ end
39
+ end
40
+ end
41
+ end
42
+ end
@@ -0,0 +1,65 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Lutaml
4
+ module Lml
5
+ class ModelCompiler
6
+ # Evaluates hydrated instances against their compiled
7
+ # models (unknown attributes, enum membership, nesting).
8
+ module Validation
9
+ private
10
+
11
+ def validate_instance(instance, errors, path = "root")
12
+ if instance.instance && Array(instance.attributes).empty?
13
+ validate_instance(instance.instance, errors, "#{path}.instance")
14
+ return
15
+ end
16
+
17
+ attrs = Array(instance.attributes)
18
+ type_attr = attrs.find { |a| a.name == "type" }
19
+ type_name = type_attr ? type_attr.value.to_s : instance.type
20
+ klass = @compiled[demodulize(type_name)]
21
+ unless klass
22
+ errors << "#{path}: unknown type '#{type_name}'"
23
+ return
24
+ end
25
+
26
+ schema_attrs = klass.attributes.keys.map(&:to_s)
27
+ present_attrs = attrs.map(&:name)
28
+ schema_set = schema_attrs.to_set
29
+ present_set = present_attrs.to_set
30
+
31
+ unknown = present_set - schema_set - Set.new(%w[type])
32
+ unknown.each do |name|
33
+ errors << "#{path}.#{name}: attribute not defined on #{type_name}"
34
+ end
35
+
36
+ required = klass.attributes.values
37
+ .reject { |v| v.collection? || v.options.key?(:default) }
38
+ .to_set { |v| v.name.to_s }
39
+
40
+ missing = required - present_set
41
+ missing.each do |name|
42
+ errors << "#{path}.#{name}: required attribute missing (cardinality min >= 1)"
43
+ end
44
+
45
+ attrs.each do |attr|
46
+ next unless schema_attrs.include?(attr.name)
47
+
48
+ attr_def = klass.attributes[attr.name.to_sym]
49
+ next unless attr_def
50
+
51
+ next unless attr_def.collection? && attr.instances.any?
52
+
53
+ attr.instances.each_with_index do |nested, i|
54
+ validate_instance(nested, errors, "#{path}.#{attr.name}[#{i}]")
55
+ end
56
+ end
57
+
58
+ return unless instance.instance
59
+
60
+ validate_instance(instance.instance, errors, "#{path}.instance")
61
+ end
62
+ end
63
+ end
64
+ end
65
+ end