Skip to content

Commit

Permalink
Schema check occurrences (#35)
Browse files Browse the repository at this point in the history
  • Loading branch information
nichtich committed Mar 19, 2018
1 parent fec287a commit 5981843
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 2 deletions.
2 changes: 2 additions & 0 deletions lib/PICA/Schema.pm
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,8 @@ language|https://format.gbv.de/schema/avram/specification>, for instance:
See L<PICA::Schema::Builder> to automatically construct schemas from PICA
records.
Schema information can be included in PICA XML with L<PICA::Writer::XML>.
=head1 METHODS
=head2 check( $record [, %options ] )
Expand Down
25 changes: 23 additions & 2 deletions t/files/schema-tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ schemas:
021A:
fields:
021A:
required: true
required: 1
subfields:
a:
required: 1
Expand All @@ -14,11 +14,17 @@ schemas:
021A-repeatable:
fields:
021A:
repeatable: true
repeatable: 1
021A-empty-subfields:
fields:
021A:
subfields: {}
occurrences:
fields:
028C/01:
required: 1
222X:
required: 0

records:
021A: "021A $atitle"
Expand All @@ -29,6 +35,8 @@ records:
021A-unordered-subfields: "021A $dsubtitle$atitle"
021A-subfield: "021A $atitle$atitle"
099X: "099X $xy"
occurrences: "028C/01 $dEmma$aGoldman\n222X/123 $x23"
occurrences-missing: "028C $dEmma$aGoldman"

tests:

Expand Down Expand Up @@ -106,6 +114,19 @@ tests:
options:
ignore_subfield_order: 1

- schema: occurrences
record: occurrences-missing
result:
- tag: 028C
message: unknown field 028C
- tag: 028C
occurrence: '01'
message: missing field 028C/01
required: 1

- schema: occurrences
record: occurrences

# TODO:
# - check fields in level 1 and level 2 (uniqueness per local copy!)

0 comments on commit 5981843

Please sign in to comment.