lutaml-model 0.8.177 → 0.8.179
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.
- checksums.yaml +4 -4
- data/lib/compat/opal/lutaml_model_boot.rb +5 -0
- data/lib/lutaml/model/schema/xml_compiler/supported_data_types.rb +3 -0
- data/lib/lutaml/model/type/g_day.rb +32 -0
- data/lib/lutaml/model/type/g_month.rb +31 -0
- data/lib/lutaml/model/type/g_month_day.rb +32 -0
- data/lib/lutaml/model/type/g_year.rb +32 -0
- data/lib/lutaml/model/type/g_year_month.rb +32 -0
- data/lib/lutaml/model/type.rb +10 -0
- data/lib/lutaml/model/version.rb +1 -1
- data/lib/lutaml/xml/xsd_validator.rb +72 -20
- data/spec/lutaml/model/schema/xml_compiler_runtime_spec.rb +47 -0
- data/spec/lutaml/xml/validate_xml_with_constructs_spec.rb +15 -1
- data/spec/lutaml/xml/validate_xml_with_spec.rb +6 -1
- metadata +7 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 5bcb549c4874d482186701e9dab0f679acbdd607e8de1881f456addad166ffe8
|
|
4
|
+
data.tar.gz: 5730a91820996ad70d240521f7562268d92f1a682cea0c89ffded960a93e6b70
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: d86a6050dcabfb0d5c9fc1850b4cabac230c90f7ecea5ef2cdb22ab7f6114c7dd488d4ba4e4049182414e218150dc9e5f2ba6caecd60a731d9840ae9c0b95a09
|
|
7
|
+
data.tar.gz: 02c8df9d2b236471abff47a0cbc225a1c4fd00179c5bd543361f4eb9b72575cc2b696f4c490d9230c96c02e2cc7c4eb51aac6cd495f54233a2bac04adb8c35a1
|
|
@@ -346,6 +346,11 @@ require "lutaml/model/type/decimal"
|
|
|
346
346
|
require "lutaml/model/type/duration"
|
|
347
347
|
require "lutaml/model/type/email_address"
|
|
348
348
|
require "lutaml/model/type/float"
|
|
349
|
+
require "lutaml/model/type/g_day"
|
|
350
|
+
require "lutaml/model/type/g_month"
|
|
351
|
+
require "lutaml/model/type/g_month_day"
|
|
352
|
+
require "lutaml/model/type/g_year"
|
|
353
|
+
require "lutaml/model/type/g_year_month"
|
|
349
354
|
require "lutaml/model/type/hash"
|
|
350
355
|
require "lutaml/model/type/hex_binary"
|
|
351
356
|
require "lutaml/model/type/hostname"
|
|
@@ -112,6 +112,9 @@ module Lutaml
|
|
|
112
112
|
# when the name is not a skippable built-in.
|
|
113
113
|
def primitive_symbol(value)
|
|
114
114
|
info = TABLE[value.to_sym]
|
|
115
|
+
info ||= TABLE.find do |name, _|
|
|
116
|
+
Utils.snake_case(name.to_s) == value.to_s
|
|
117
|
+
end&.last
|
|
115
118
|
return nil unless info && info[:skippable]
|
|
116
119
|
|
|
117
120
|
Utils.snake_case(info[:class_name].split("::").last)
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Lutaml
|
|
4
|
+
module Model
|
|
5
|
+
module Type
|
|
6
|
+
# XML Schema gDay datatype: a recurring calendar day of month —
|
|
7
|
+
# ---24, ---24Z, ---24+05:30.
|
|
8
|
+
#
|
|
9
|
+
# @example Using GDay type
|
|
10
|
+
# attribute :closes_on, :g_day
|
|
11
|
+
class GDay < String
|
|
12
|
+
PATTERN = /\A---(?:0[1-9]|[12]\d|3[01])(Z|[+-]\d{2}:\d{2})?\z/
|
|
13
|
+
|
|
14
|
+
def self.cast(value, _options = EMPTY_OPTIONS)
|
|
15
|
+
value&.to_s
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
def self.valid?(value)
|
|
19
|
+
value.is_a?(::String) ? value.match?(PATTERN) : !cast(value).nil?
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
def self.json_schema_format
|
|
23
|
+
"gday"
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
def self.default_xsd_type
|
|
27
|
+
"xs:gDay"
|
|
28
|
+
end
|
|
29
|
+
end
|
|
30
|
+
end
|
|
31
|
+
end
|
|
32
|
+
end
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Lutaml
|
|
4
|
+
module Model
|
|
5
|
+
module Type
|
|
6
|
+
# XML Schema gMonth datatype: a calendar month — --11, --11Z, --11+05:30.
|
|
7
|
+
#
|
|
8
|
+
# @example Using GMonth type
|
|
9
|
+
# attribute :renews_in, :g_month
|
|
10
|
+
class GMonth < String
|
|
11
|
+
PATTERN = /\A--(?:0[1-9]|1[0-2])(Z|[+-]\d{2}:\d{2})?\z/
|
|
12
|
+
|
|
13
|
+
def self.cast(value, _options = EMPTY_OPTIONS)
|
|
14
|
+
value&.to_s
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
def self.valid?(value)
|
|
18
|
+
value.is_a?(::String) ? value.match?(PATTERN) : !cast(value).nil?
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
def self.json_schema_format
|
|
22
|
+
"gmonth"
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
def self.default_xsd_type
|
|
26
|
+
"xs:gMonth"
|
|
27
|
+
end
|
|
28
|
+
end
|
|
29
|
+
end
|
|
30
|
+
end
|
|
31
|
+
end
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Lutaml
|
|
4
|
+
module Model
|
|
5
|
+
module Type
|
|
6
|
+
# XML Schema gMonthDay datatype: a recurring calendar day —
|
|
7
|
+
# --11-24, --11-24Z, --11-24+05:30.
|
|
8
|
+
#
|
|
9
|
+
# @example Using GMonthDay type
|
|
10
|
+
# attribute :anniversary, :g_month_day
|
|
11
|
+
class GMonthDay < String
|
|
12
|
+
PATTERN = /\A--(?:0[1-9]|1[0-2])-(?:0[1-9]|[12]\d|3[01])(Z|[+-]\d{2}:\d{2})?\z/
|
|
13
|
+
|
|
14
|
+
def self.cast(value, _options = EMPTY_OPTIONS)
|
|
15
|
+
value&.to_s
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
def self.valid?(value)
|
|
19
|
+
value.is_a?(::String) ? value.match?(PATTERN) : !cast(value).nil?
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
def self.json_schema_format
|
|
23
|
+
"gmonthday"
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
def self.default_xsd_type
|
|
27
|
+
"xs:gMonthDay"
|
|
28
|
+
end
|
|
29
|
+
end
|
|
30
|
+
end
|
|
31
|
+
end
|
|
32
|
+
end
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Lutaml
|
|
4
|
+
module Model
|
|
5
|
+
module Type
|
|
6
|
+
# XML Schema gYear datatype: a calendar year — 2026, 0942, 2026Z,
|
|
7
|
+
# 2026+05:30.
|
|
8
|
+
#
|
|
9
|
+
# @example Using GYear type
|
|
10
|
+
# attribute :reported, :g_year
|
|
11
|
+
class GYear < String
|
|
12
|
+
PATTERN = /\A-?\d{4,}(Z|[+-]\d{2}:\d{2})?\z/
|
|
13
|
+
|
|
14
|
+
def self.cast(value, _options = EMPTY_OPTIONS)
|
|
15
|
+
value&.to_s
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
def self.valid?(value)
|
|
19
|
+
value.is_a?(::String) ? value.match?(PATTERN) : !cast(value).nil?
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
def self.json_schema_format
|
|
23
|
+
"gyear"
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
def self.default_xsd_type
|
|
27
|
+
"xs:gYear"
|
|
28
|
+
end
|
|
29
|
+
end
|
|
30
|
+
end
|
|
31
|
+
end
|
|
32
|
+
end
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Lutaml
|
|
4
|
+
module Model
|
|
5
|
+
module Type
|
|
6
|
+
# XML Schema gYearMonth datatype: a calendar year and month —
|
|
7
|
+
# 2026-11, 0942-01Z, 2026-11+05:30.
|
|
8
|
+
#
|
|
9
|
+
# @example Using GYearMonth type
|
|
10
|
+
# attribute :issued, :g_year_month
|
|
11
|
+
class GYearMonth < String
|
|
12
|
+
PATTERN = /\A-?\d{4,}-(?:0[1-9]|1[0-2])(Z|[+-]\d{2}:\d{2})?\z/
|
|
13
|
+
|
|
14
|
+
def self.cast(value, _options = EMPTY_OPTIONS)
|
|
15
|
+
value&.to_s
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
def self.valid?(value)
|
|
19
|
+
value.is_a?(::String) ? value.match?(PATTERN) : !cast(value).nil?
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
def self.json_schema_format
|
|
23
|
+
"gyearmonth"
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
def self.default_xsd_type
|
|
27
|
+
"xs:gYearMonth"
|
|
28
|
+
end
|
|
29
|
+
end
|
|
30
|
+
end
|
|
31
|
+
end
|
|
32
|
+
end
|
data/lib/lutaml/model/type.rb
CHANGED
|
@@ -38,6 +38,11 @@ module Lutaml
|
|
|
38
38
|
autoload :DateTimeWithTimezone, "#{__dir__}/type/date_time_with_timezone"
|
|
39
39
|
autoload :DayTimeDuration, "#{__dir__}/type/day_time_duration"
|
|
40
40
|
autoload :YearMonthDuration, "#{__dir__}/type/year_month_duration"
|
|
41
|
+
autoload :GYear, "#{__dir__}/type/g_year"
|
|
42
|
+
autoload :GYearMonth, "#{__dir__}/type/g_year_month"
|
|
43
|
+
autoload :GMonth, "#{__dir__}/type/g_month"
|
|
44
|
+
autoload :GMonthDay, "#{__dir__}/type/g_month_day"
|
|
45
|
+
autoload :GDay, "#{__dir__}/type/g_day"
|
|
41
46
|
|
|
42
47
|
# Error classes (defined in error/type/ but under Type namespace)
|
|
43
48
|
autoload :InvalidValueError, "#{__dir__}/error/type/invalid_value_error"
|
|
@@ -82,6 +87,11 @@ module Lutaml
|
|
|
82
87
|
date_time_with_timezone: "Lutaml::Model::Type::DateTimeWithTimezone",
|
|
83
88
|
day_time_duration: "Lutaml::Model::Type::DayTimeDuration",
|
|
84
89
|
year_month_duration: "Lutaml::Model::Type::YearMonthDuration",
|
|
90
|
+
g_year: "Lutaml::Model::Type::GYear",
|
|
91
|
+
g_year_month: "Lutaml::Model::Type::GYearMonth",
|
|
92
|
+
g_month: "Lutaml::Model::Type::GMonth",
|
|
93
|
+
g_month_day: "Lutaml::Model::Type::GMonthDay",
|
|
94
|
+
g_day: "Lutaml::Model::Type::GDay",
|
|
85
95
|
}.freeze
|
|
86
96
|
|
|
87
97
|
BUILTIN_CLASSES =
|
data/lib/lutaml/model/version.rb
CHANGED
|
@@ -6,9 +6,16 @@ module Lutaml
|
|
|
6
6
|
module Xml
|
|
7
7
|
# Validates a serialized XML string against an XSD schema file.
|
|
8
8
|
#
|
|
9
|
-
# Backs the `validate_xml_with` class macro (issue #264).
|
|
10
|
-
#
|
|
11
|
-
# on
|
|
9
|
+
# Backs the `validate_xml_with` class macro (issue #264). Routing is
|
|
10
|
+
# engine-agnostic through moxml (#1184): schemas compile and validate
|
|
11
|
+
# on the CONFIGURED engine — `Moxml::XSD.supported?` answers without
|
|
12
|
+
# raising, and engines without a validator (ox, oga, rexml) fall back
|
|
13
|
+
# to the historical Nokogiri path, keeping its requirement error when
|
|
14
|
+
# the gem is absent. The leptris engine carries a validator.
|
|
15
|
+
#
|
|
16
|
+
# Strict parsing: libxml2 recovery would otherwise repair malformed
|
|
17
|
+
# input and report it as schema-valid. Malformed input raises
|
|
18
|
+
# Moxml::ParseError (the normalized class; line and column carried).
|
|
12
19
|
#
|
|
13
20
|
# Compiled schemas are memoized by absolute path: the XSD files are
|
|
14
21
|
# constant for the life of the process, so each is read and compiled once
|
|
@@ -17,10 +24,8 @@ module Lutaml
|
|
|
17
24
|
# Not to be confused with Schema::Xsd::SchemaValidator, which checks
|
|
18
25
|
# that an XSD document itself is well-formed XSD.
|
|
19
26
|
module XsdValidator
|
|
20
|
-
# Concurrent (and a working Nokogiri) are unavailable under Opal, so
|
|
21
|
-
# the memoization store is only built off-Opal. validate raises a clear
|
|
22
|
-
# NotImplementedError under Opal before this store is ever consulted.
|
|
23
27
|
@schemas = ::Concurrent::Map.new unless RUBY_ENGINE == "opal"
|
|
28
|
+
@nokogiri_schemas = ::Concurrent::Map.new unless RUBY_ENGINE == "opal"
|
|
24
29
|
|
|
25
30
|
# @param xml [String] an XML document
|
|
26
31
|
# @param schema_paths [Array<String>] paths to XSD schema files
|
|
@@ -31,24 +36,64 @@ module Lutaml
|
|
|
31
36
|
|
|
32
37
|
if RUBY_ENGINE == "opal"
|
|
33
38
|
raise NotImplementedError,
|
|
34
|
-
"XSD schema validation (validate_xml_with) requires
|
|
35
|
-
"
|
|
39
|
+
"XSD schema validation (validate_xml_with) requires an " \
|
|
40
|
+
"XML engine with schema validation, which is not " \
|
|
41
|
+
"available under Opal."
|
|
36
42
|
end
|
|
37
43
|
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
44
|
+
if engine_supports_xsd?
|
|
45
|
+
document = context.parse(xml, strict: true)
|
|
46
|
+
paths.flat_map do |path|
|
|
47
|
+
schema_for(path)
|
|
48
|
+
.validate(document)
|
|
49
|
+
.map { |error| Error::SchemaValidationError.new(error.message, path) }
|
|
50
|
+
end
|
|
51
|
+
else
|
|
52
|
+
ensure_nokogiri!
|
|
53
|
+
begin
|
|
54
|
+
document = ::Nokogiri::XML(xml, &:strict)
|
|
55
|
+
rescue ::Nokogiri::XML::SyntaxError => e
|
|
56
|
+
# One error contract across lanes: the fallback normalizes
|
|
57
|
+
# to the same Moxml::ParseError the engine path raises.
|
|
58
|
+
raise Moxml::ParseError.new(e.message, line: e.line,
|
|
59
|
+
column: e.column)
|
|
60
|
+
end
|
|
61
|
+
paths.flat_map do |path|
|
|
62
|
+
nokogiri_schema_for(path)
|
|
63
|
+
.validate(document)
|
|
64
|
+
.map { |error| Error::SchemaValidationError.new(error.message, path) }
|
|
65
|
+
end
|
|
46
66
|
end
|
|
47
67
|
end
|
|
48
68
|
|
|
69
|
+
# The configured engine as a moxml backend symbol. Config's plain
|
|
70
|
+
# symbol (nokogiri, leptris, ...) — NOT the AdapterResolver's
|
|
71
|
+
# configured type, whose FIXED_ADAPTER_TYPE sentinel is internal
|
|
72
|
+
# and must never reach Moxml (the closed #1183 leak).
|
|
73
|
+
def self.backend
|
|
74
|
+
Lutaml::Model::Config.xml_adapter_type || :nokogiri
|
|
75
|
+
end
|
|
76
|
+
|
|
77
|
+
def self.engine_supports_xsd?
|
|
78
|
+
Moxml::XSD.supported?(context)
|
|
79
|
+
rescue Moxml::AdapterError, LoadError
|
|
80
|
+
false
|
|
81
|
+
end
|
|
82
|
+
|
|
83
|
+
def self.context
|
|
84
|
+
@context ||= Moxml.new(backend)
|
|
85
|
+
end
|
|
86
|
+
|
|
49
87
|
def self.schema_for(path)
|
|
50
88
|
@schemas.compute_if_absent(path) do
|
|
51
|
-
|
|
89
|
+
# One error contract across lanes: engines with file-based
|
|
90
|
+
# compilation (leptris) read the schema themselves and would
|
|
91
|
+
# surface their own error for a missing path; checking here
|
|
92
|
+
# keeps the missing-schema case a plain Errno::ENOENT on
|
|
93
|
+
# every engine.
|
|
94
|
+
raise Errno::ENOENT, path unless File.exist?(path)
|
|
95
|
+
|
|
96
|
+
context.xsd_file(path)
|
|
52
97
|
end
|
|
53
98
|
end
|
|
54
99
|
|
|
@@ -56,11 +101,18 @@ module Lutaml
|
|
|
56
101
|
require "nokogiri"
|
|
57
102
|
rescue LoadError
|
|
58
103
|
raise Error::XmlConfigurationError,
|
|
59
|
-
"XSD schema validation (validate_xml_with) requires
|
|
60
|
-
"
|
|
104
|
+
"XSD schema validation (validate_xml_with) requires an " \
|
|
105
|
+
"XML engine with schema validation; add `gem \"nokogiri\"` " \
|
|
106
|
+
"to your Gemfile"
|
|
107
|
+
end
|
|
108
|
+
|
|
109
|
+
def self.nokogiri_schema_for(path)
|
|
110
|
+
@nokogiri_schemas.compute_if_absent(path) do
|
|
111
|
+
::Nokogiri::XML::Schema(File.read(path))
|
|
112
|
+
end
|
|
61
113
|
end
|
|
62
114
|
|
|
63
|
-
private_class_method :ensure_nokogiri!, :
|
|
115
|
+
private_class_method :ensure_nokogiri!, :nokogiri_schema_for
|
|
64
116
|
end
|
|
65
117
|
end
|
|
66
118
|
end
|
|
@@ -167,4 +167,51 @@ RSpec.describe "runtime XSD class loading" do
|
|
|
167
167
|
expect(minimal.note).to be_nil
|
|
168
168
|
end
|
|
169
169
|
end
|
|
170
|
+
|
|
171
|
+
describe "snake-spelled builtin union members" do
|
|
172
|
+
let(:xsd) do
|
|
173
|
+
<<~XSD
|
|
174
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
|
175
|
+
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
|
|
176
|
+
<xs:simpleType name="dateOrYear">
|
|
177
|
+
<xs:union memberTypes="xs:date xs:gYearMonth xs:gYear"/>
|
|
178
|
+
</xs:simpleType>
|
|
179
|
+
<xs:complexType name="StampType">
|
|
180
|
+
<xs:sequence>
|
|
181
|
+
<xs:element name="when" type="dateOrYear"/>
|
|
182
|
+
</xs:sequence>
|
|
183
|
+
</xs:complexType>
|
|
184
|
+
<xs:element name="stamp" type="StampType"/>
|
|
185
|
+
</xs:schema>
|
|
186
|
+
XSD
|
|
187
|
+
end
|
|
188
|
+
|
|
189
|
+
it "resolves union memberTypes against the table in either spelling" do
|
|
190
|
+
sources = Lutaml::Model::Schema.from_xml(
|
|
191
|
+
xsd, output_dir: "snake_builtin_models", load_classes: true
|
|
192
|
+
)
|
|
193
|
+
|
|
194
|
+
stamp_source = sources.values.find { |src| src.include?("StampType") }
|
|
195
|
+
expect(stamp_source).not_to include("g_year_month")
|
|
196
|
+
end
|
|
197
|
+
end
|
|
198
|
+
|
|
199
|
+
describe "g-date types" do
|
|
200
|
+
it "registers :g_year_month so relaton-style models parse" do
|
|
201
|
+
expect(Lutaml::Model::Type::GYearMonth.cast("2026-11")).to eq("2026-11")
|
|
202
|
+
expect(Lutaml::Model::Type::TYPE_CODES).to include(:g_year_month)
|
|
203
|
+
expect(Lutaml::Model::Type::TYPE_CODES[:g_year_month])
|
|
204
|
+
.to eq("Lutaml::Model::Type::GYearMonth")
|
|
205
|
+
end
|
|
206
|
+
|
|
207
|
+
it "validates the lexical forms" do
|
|
208
|
+
expect(Lutaml::Model::Type::GYearMonth.valid?("2026-11")).to be(true)
|
|
209
|
+
expect(Lutaml::Model::Type::GYearMonth.valid?("2026-13")).to be(false)
|
|
210
|
+
expect(Lutaml::Model::Type::GYear.valid?("0942")).to be(true)
|
|
211
|
+
expect(Lutaml::Model::Type::GDay.valid?("---24")).to be(true)
|
|
212
|
+
expect(Lutaml::Model::Type::GDay.valid?("24")).to be(false)
|
|
213
|
+
expect(Lutaml::Model::Type::GMonthDay.valid?("--11-24")).to be(true)
|
|
214
|
+
expect(Lutaml::Model::Type::GMonth.valid?("--11")).to be(true)
|
|
215
|
+
end
|
|
216
|
+
end
|
|
170
217
|
end
|
|
@@ -91,8 +91,11 @@ RSpec.describe "validate_xml_with XSD constructs" do
|
|
|
91
91
|
it "collects missing required attribute violations" do
|
|
92
92
|
errors = product(id: nil).validate
|
|
93
93
|
|
|
94
|
+
# Engines phrase the violation differently ("attribute 'id' is
|
|
95
|
+
# required" on the nokogiri lane, "attribute 'id': required but
|
|
96
|
+
# absent" on the leptris lane); the assertion stays phrasing-neutral.
|
|
94
97
|
expect(errors.map(&:message)).to include(
|
|
95
|
-
a_string_including("
|
|
98
|
+
a_string_including("id", "required"),
|
|
96
99
|
)
|
|
97
100
|
end
|
|
98
101
|
|
|
@@ -185,6 +188,17 @@ RSpec.describe "validate_xml_with XSD constructs" do
|
|
|
185
188
|
end
|
|
186
189
|
|
|
187
190
|
it "rejects a document missing the target namespace" do
|
|
191
|
+
# The leptris engine's targetNamespace qualification fix
|
|
192
|
+
# (leptris#2158, tracked as leptris/leptris-ruby#679) merged after
|
|
193
|
+
# the v1.9.442 engine tag, so no released leptris gem carries it
|
|
194
|
+
# yet; the cell gates until a gem build ships the fix. The default
|
|
195
|
+
# nokogiri lane enforces it and runs the assertion.
|
|
196
|
+
engine = Lutaml::Model::Config.xml_adapter_type&.to_s
|
|
197
|
+
if engine == "leptris"
|
|
198
|
+
skip "leptris targetNamespace enforcement pending a leptris " \
|
|
199
|
+
"gem carrying leptris#2158"
|
|
200
|
+
end
|
|
201
|
+
|
|
188
202
|
xml = "<address><city>Berlin</city></address>"
|
|
189
203
|
|
|
190
204
|
expect(XsdNamespacedDoc.validate_xml(xml)).not_to be_empty
|
|
@@ -84,10 +84,15 @@ RSpec.describe "validate_xml_with" do
|
|
|
84
84
|
end.to raise_error(Lutaml::Model::ValidationError, /age/)
|
|
85
85
|
end
|
|
86
86
|
|
|
87
|
+
# Malformed input raises instead of recovering; the error class is
|
|
88
|
+
# moxml's normalized ParseError (engine-independent) now that
|
|
89
|
+
# validation routes through the moxml layer (#1184). The position
|
|
90
|
+
# format is engine-specific (libxml2 reports a line, leptris a byte
|
|
91
|
+
# offset), so the assertion accepts either.
|
|
87
92
|
it "raises a parse error for malformed XML instead of recovering" do
|
|
88
93
|
expect do
|
|
89
94
|
XsdValidatedPerson.validate_xml("<person><name>Alice</name>")
|
|
90
|
-
end.to raise_error(
|
|
95
|
+
end.to raise_error(Moxml::ParseError, /Line: \d+|byte \d+/)
|
|
91
96
|
end
|
|
92
97
|
end
|
|
93
98
|
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: lutaml-model
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.8.
|
|
4
|
+
version: 0.8.179
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Ribose Inc.
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: exe
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2026-11-
|
|
11
|
+
date: 2026-11-25 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: base64
|
|
@@ -674,6 +674,11 @@ files:
|
|
|
674
674
|
- lib/lutaml/model/type/duration.rb
|
|
675
675
|
- lib/lutaml/model/type/email_address.rb
|
|
676
676
|
- lib/lutaml/model/type/float.rb
|
|
677
|
+
- lib/lutaml/model/type/g_day.rb
|
|
678
|
+
- lib/lutaml/model/type/g_month.rb
|
|
679
|
+
- lib/lutaml/model/type/g_month_day.rb
|
|
680
|
+
- lib/lutaml/model/type/g_year.rb
|
|
681
|
+
- lib/lutaml/model/type/g_year_month.rb
|
|
677
682
|
- lib/lutaml/model/type/hash.rb
|
|
678
683
|
- lib/lutaml/model/type/hex_binary.rb
|
|
679
684
|
- lib/lutaml/model/type/hostname.rb
|