Skip to content

Commit

Permalink
Merge pull request #124 from sul-dlss/validate-sourceId
Browse files Browse the repository at this point in the history
Validate the pattern of sourceId
  • Loading branch information
jcoyne authored Aug 29, 2020
2 parents f327dca + 9374c93 commit 30b5878
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 20 deletions.
2 changes: 1 addition & 1 deletion lib/cocina/models/identification.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
module Cocina
module Models
class Identification < Struct
# Unique identifier in some other system. This is because a large proportion of what is deposited in SDR, historically and currently, are representations of objects that are also represented in other systems. For example, digitized paper and A/V collections have physical manifestations, and those physical objects are managed in systems that have their own identifiers. Similarly, books have barcodes, archival materials have collection numbers and physical locations, etc. The sourceId allows determining if an item has been deposited before and where to look for the original item if you're looking at its SDR representation.
# Unique identifier in some other system. This is because a large proportion of what is deposited in SDR, historically and currently, are representations of objects that are also represented in other systems. For example, digitized paper and A/V collections have physical manifestations, and those physical objects are managed in systems that have their own identifiers. Similarly, books have barcodes, archival materials have collection numbers and physical locations, etc. The sourceId allows determining if an item has been deposited before and where to look for the original item if you're looking at its SDR representation. The format is: "namespace:identifier"

# example: sul:PC0170_s3_Fiesta_Bowl_2012-01-02_210609_2026
attribute :sourceId, Types::Strict::String.meta(omittable: true)
Expand Down
2 changes: 1 addition & 1 deletion lib/cocina/models/request_identification.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
module Cocina
module Models
class RequestIdentification < Struct
# Unique identifier in some other system. This is because a large proportion of what is deposited in SDR, historically and currently, are representations of objects that are also represented in other systems. For example, digitized paper and A/V collections have physical manifestations, and those physical objects are managed in systems that have their own identifiers. Similarly, books have barcodes, archival materials have collection numbers and physical locations, etc. The sourceId allows determining if an item has been deposited before and where to look for the original item if you're looking at its SDR representation.
# Unique identifier in some other system. This is because a large proportion of what is deposited in SDR, historically and currently, are representations of objects that are also represented in other systems. For example, digitized paper and A/V collections have physical manifestations, and those physical objects are managed in systems that have their own identifiers. Similarly, books have barcodes, archival materials have collection numbers and physical locations, etc. The sourceId allows determining if an item has been deposited before and where to look for the original item if you're looking at its SDR representation. The format is: "namespace:identifier"

# example: sul:PC0170_s3_Fiesta_Bowl_2012-01-02_210609_2026
attribute :sourceId, Types::Strict::String
Expand Down
9 changes: 9 additions & 0 deletions lib/cocina/models/source_id.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# frozen_string_literal: true

module Cocina
module Models
SourceId = Types::String.constrained(
format: /^.+:.+$/i
)
end
end
31 changes: 13 additions & 18 deletions openapi.yml
Original file line number Diff line number Diff line change
Expand Up @@ -842,15 +842,7 @@ components:
additionalProperties: false
properties:
sourceId:
type: string
description: >
Unique identifier in some other system. This is because a large proportion of what is deposited in SDR,
historically and currently, are representations of objects that are also represented in other systems.
For example, digitized paper and A/V collections have physical manifestations, and those physical objects are managed
in systems that have their own identifiers. Similarly, books have barcodes, archival materials have collection numbers
and physical locations, etc. The sourceId allows determining if an item has been deposited before and where to
look for the original item if you're looking at its SDR representation.
example: 'sul:PC0170_s3_Fiesta_Bowl_2012-01-02_210609_2026'
$ref: '#/components/schemas/SourceId'
catalogLinks:
type: array
items:
Expand Down Expand Up @@ -1179,15 +1171,7 @@ components:
additionalProperties: false
properties:
sourceId:
type: string
description: >
Unique identifier in some other system. This is because a large proportion of what is deposited in SDR,
historically and currently, are representations of objects that are also represented in other systems.
For example, digitized paper and A/V collections have physical manifestations, and those physical objects are managed
in systems that have their own identifiers. Similarly, books have barcodes, archival materials have collection numbers
and physical locations, etc. The sourceId allows determining if an item has been deposited before and where to
look for the original item if you're looking at its SDR representation.
example: 'sul:PC0170_s3_Fiesta_Bowl_2012-01-02_210609_2026'
$ref: '#/components/schemas/SourceId'
catalogLinks:
type: array
items:
Expand Down Expand Up @@ -1254,3 +1238,14 @@ components:
$ref: "#/components/schemas/DescriptiveValue"
source:
$ref: "#/components/schemas/Source"
SourceId:
type: string
pattern: '^.+:.+$'
description: >
Unique identifier in some other system. This is because a large proportion of what is deposited in SDR,
historically and currently, are representations of objects that are also represented in other systems.
For example, digitized paper and A/V collections have physical manifestations, and those physical objects are managed
in systems that have their own identifiers. Similarly, books have barcodes, archival materials have collection numbers
and physical locations, etc. The sourceId allows determining if an item has been deposited before and where to
look for the original item if you're looking at its SDR representation. The format is: "namespace:identifier"
example: 'sul:PC0170_s3_Fiesta_Bowl_2012-01-02_210609_2026'

0 comments on commit 30b5878

Please sign in to comment.