Skip to content

Commit

Permalink
Use regex for validating dateCreated #2124
Browse files Browse the repository at this point in the history
The regex checks for correct possible month and day digits, but does not check if a month has 30 oder 31 days.
  • Loading branch information
TobiasNx committed Jan 14, 2025
1 parent ed98df3 commit 62a8feb
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions src/main/resources/alma/fix/describedBy.fix
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,9 @@ if any_match("008", "^\\d{6}\\D.*") # 008/00-05 is the correct form for the cata
substring("@initialCataloguingDate","0","6")
end

if any_match("@initialCataloguingDate","^[0-4]\\d*") # Complete dates after 2000
if any_match("@initialCataloguingDate","^[0-4]\\d(0[1-9]|1[012])(0[1-9]|[12][0-9]|3[01])") # Complete dates after 2000
prepend("@initialCataloguingDate","20")
elsif any_match("@initialCataloguingDate","\\d*") # Complete dates before 2000
elsif any_match("@initialCataloguingDate","\\d{2}(0[1-9]|1[012])(0[1-9]|[12][0-9]|3[01])") # Complete dates before 2000
prepend("@initialCataloguingDate","19")
else
copy_field("MNG .b","@initialCataloguingDate")
Expand Down
2 changes: 1 addition & 1 deletion src/test/resources/alma-fix/99373737680006441.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
},
"object" : {
"id" : "https://lobid.org/marcxml/99373737680006441",
"dateCreated" : "2019-78-06",
"dateCreated" : "2024-02-28",
"dateModified" : "2024-03-07",
"type" : [ "DataFeedItem" ],
"label" : "hbz-Ressource 99373737680006441 im Exportformat MARC21 XML",
Expand Down

0 comments on commit 62a8feb

Please sign in to comment.