cocina-models 0.131.0 → 0.132.0
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/Gemfile.lock +2 -2
- data/lib/cocina/models/validators/description_date_time_visitor_validator.rb +5 -1
- data/lib/cocina/models/validators/description_role_source_code_visitor_validator.rb +4 -7
- data/lib/cocina/models/validators/json_schema_validator.rb +2 -1
- data/lib/cocina/models/version.rb +1 -1
- data/schema.json +10 -5
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 6a61867c1ae0703869cce27ced15c5698d5e4e93b5792e6e1ae559ca55965d39
|
|
4
|
+
data.tar.gz: e091f101f3922c69833aca4117f4d8d011f55d0959e2463e8f151bf1ba6f8d6a
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: b8b8e322eeed3c9a59831ef76a664c79cd6438224e4ec92de4448c9da17ea10c20874758fd968e270523ceb13acce529cc6b13e596b925b05aac77ba93accfa9
|
|
7
|
+
data.tar.gz: bace81574ac19ed81b453caeec3530c940e1c4bc41d94e316726ea5f42092092363e0c4138fb51fe693732af3f74db5bea5b629f0ab5a60b1db57cf3ca05c802
|
data/Gemfile.lock
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
PATH
|
|
2
2
|
remote: .
|
|
3
3
|
specs:
|
|
4
|
-
cocina-models (0.
|
|
4
|
+
cocina-models (0.132.0)
|
|
5
5
|
activesupport
|
|
6
6
|
cocina_display
|
|
7
7
|
deprecation
|
|
@@ -226,7 +226,7 @@ CHECKSUMS
|
|
|
226
226
|
bigdecimal (4.1.2) sha256=53d217666027eab4280346fba98e7d5b66baaae1b9c3c1c0ffe89d48188a3fbd
|
|
227
227
|
builder (3.3.0) sha256=497918d2f9dca528fdca4b88d84e4ef4387256d984b8154e9d5d3fe5a9c8835f
|
|
228
228
|
bundler (4.0.17) sha256=214e21431b5665dd2f99df8a5511c6b151d7a72e8015c8b38f8b775b61cbb6c1
|
|
229
|
-
cocina-models (0.
|
|
229
|
+
cocina-models (0.132.0)
|
|
230
230
|
cocina_display (2.9.0) sha256=00e97cf826dafd5c547ca87b58e55f1d3bfa68fa4ddcddbbe25b4d9d9ed05d8f
|
|
231
231
|
concurrent-ruby (1.3.8) sha256=b2f1be836e968ccc78ccfce277ea79c72a88633f22306782c16ff23fb415d1e1
|
|
232
232
|
connection_pool (3.0.2) sha256=33fff5ba71a12d2aa26cb72b1db8bba2a1a01823559fb01d29eb74c286e62e0a
|
|
@@ -7,7 +7,7 @@ module Cocina
|
|
|
7
7
|
module Validators
|
|
8
8
|
# Validates that dates of known types are type-valid using the visitor pattern.
|
|
9
9
|
class DescriptionDateTimeVisitorValidator < BaseDescriptionVisitorValidator
|
|
10
|
-
VALIDATABLE_TYPES = %w[edtf iso8601 w3cdtf].freeze
|
|
10
|
+
VALIDATABLE_TYPES = %w[edtf iso8601 marc w3cdtf].freeze
|
|
11
11
|
VALID_ENCODING_CODES = %w[edtf iso8601 marc temper w3cdtf].freeze
|
|
12
12
|
|
|
13
13
|
def visit_hash(hash:, path:) # rubocop:disable Metrics/PerceivedComplexity, Metrics/CyclomaticComplexity
|
|
@@ -135,6 +135,10 @@ module Cocina
|
|
|
135
135
|
def valid_w3cdtf?(value)
|
|
136
136
|
W3cdtfValidator.validate(value)
|
|
137
137
|
end
|
|
138
|
+
|
|
139
|
+
def valid_marc?(value)
|
|
140
|
+
MarcDateValidator.validate(value)
|
|
141
|
+
end
|
|
138
142
|
end
|
|
139
143
|
end
|
|
140
144
|
end
|
|
@@ -3,8 +3,10 @@
|
|
|
3
3
|
module Cocina
|
|
4
4
|
module Models
|
|
5
5
|
module Validators
|
|
6
|
-
# Validates contributor.role.source.code values
|
|
6
|
+
# Validates contributor.role.source.code values.
|
|
7
7
|
class DescriptionRoleSourceCodeVisitorValidator < BaseDescriptionVisitorValidator
|
|
8
|
+
VALID_CODES = %w[aat lcmpt marcrelator rbmsrel].freeze
|
|
9
|
+
|
|
8
10
|
def validate!
|
|
9
11
|
return if error_paths.empty?
|
|
10
12
|
|
|
@@ -16,7 +18,7 @@ module Cocina
|
|
|
16
18
|
|
|
17
19
|
source_code = hash.dig(:source, :code)
|
|
18
20
|
return unless source_code
|
|
19
|
-
return if
|
|
21
|
+
return if VALID_CODES.include?(source_code.downcase)
|
|
20
22
|
|
|
21
23
|
error_paths << "#{path_to_s(path)}.source.code (#{source_code})"
|
|
22
24
|
end
|
|
@@ -33,11 +35,6 @@ module Cocina
|
|
|
33
35
|
path[-2].to_s == 'role' && # we have a nested role in the path
|
|
34
36
|
path.any? { |part| part.to_s == 'contributor' } # there is a contributor in the path (any? allows for nested roles)
|
|
35
37
|
end
|
|
36
|
-
|
|
37
|
-
# Source codes allowed for contributor.role.source.code
|
|
38
|
-
def valid_codes
|
|
39
|
-
%w[aat lcmpt marcrelator rbmsrel]
|
|
40
|
-
end
|
|
41
38
|
end
|
|
42
39
|
end
|
|
43
40
|
end
|
|
@@ -36,7 +36,8 @@ module Cocina
|
|
|
36
36
|
# @return [JSONSchema validator] a cached per-definition validator
|
|
37
37
|
def self.validator_for(def_name)
|
|
38
38
|
@validators ||= {}
|
|
39
|
-
|
|
39
|
+
schema = { '$ref' => "#/$defs/#{def_name}", '$defs' => document['$defs'] }
|
|
40
|
+
@validators[def_name] ||= JSONSchema.validator_for(schema, validate_formats: true)
|
|
40
41
|
end
|
|
41
42
|
|
|
42
43
|
# @return [Hash] a hash representation of the schema.json document
|
data/schema.json
CHANGED
|
@@ -1113,7 +1113,8 @@
|
|
|
1113
1113
|
},
|
|
1114
1114
|
"uri": {
|
|
1115
1115
|
"description": "URI value of the descriptive element.",
|
|
1116
|
-
"type": "string"
|
|
1116
|
+
"type": "string",
|
|
1117
|
+
"format": "uri"
|
|
1117
1118
|
},
|
|
1118
1119
|
"standard": {
|
|
1119
1120
|
"$ref": "#/$defs/Standard"
|
|
@@ -1339,7 +1340,8 @@
|
|
|
1339
1340
|
},
|
|
1340
1341
|
"uri": {
|
|
1341
1342
|
"description": "URI for the standard or encoding.",
|
|
1342
|
-
"type": "string"
|
|
1343
|
+
"type": "string",
|
|
1344
|
+
"format": "uri"
|
|
1343
1345
|
},
|
|
1344
1346
|
"value": {
|
|
1345
1347
|
"description": "String describing the standard or encoding.",
|
|
@@ -1864,7 +1866,8 @@
|
|
|
1864
1866
|
},
|
|
1865
1867
|
"uri": {
|
|
1866
1868
|
"description": "URI value of the descriptive element.",
|
|
1867
|
-
"type": "string"
|
|
1869
|
+
"type": "string",
|
|
1870
|
+
"format": "uri"
|
|
1868
1871
|
},
|
|
1869
1872
|
"value": {
|
|
1870
1873
|
"description": "Value of the descriptive element.",
|
|
@@ -2971,7 +2974,8 @@
|
|
|
2971
2974
|
},
|
|
2972
2975
|
"uri": {
|
|
2973
2976
|
"description": "URI for the value source.",
|
|
2974
|
-
"type": "string"
|
|
2977
|
+
"type": "string",
|
|
2978
|
+
"format": "uri"
|
|
2975
2979
|
},
|
|
2976
2980
|
"value": {
|
|
2977
2981
|
"description": "String describing the value source.",
|
|
@@ -3018,7 +3022,8 @@
|
|
|
3018
3022
|
},
|
|
3019
3023
|
"uri": {
|
|
3020
3024
|
"description": "URI for the standard or encoding.",
|
|
3021
|
-
"type": "string"
|
|
3025
|
+
"type": "string",
|
|
3026
|
+
"format": "uri"
|
|
3022
3027
|
},
|
|
3023
3028
|
"value": {
|
|
3024
3029
|
"description": "String describing the standard or encoding.",
|