Skip to content

Commit

Permalink
Trappl/be 629 dont normalize isbns when harvesting (#246)
Browse files Browse the repository at this point in the history
* denormalize isbn

* version bump

* add isbnlib validation

* allow normalization
  • Loading branch information
jurajtrappl authored Feb 6, 2025
1 parent 24ca58d commit a6de941
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
8 changes: 7 additions & 1 deletion oarepo_runtime/services/schema/validation.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import re
from datetime import datetime
from idutils import normalize_pid
from isbnlib import canonical, mask

from marshmallow.exceptions import ValidationError
from marshmallow_utils.fields.edtfdatestring import EDTFValidator
Expand All @@ -11,6 +12,11 @@

def validate_identifier(value):
try:
if value["scheme"].lower() == "isbn":
canonical_isbn = canonical(value["identifier"])
value["identifier"] = mask(canonical_isbn)
return value["identifier"]

original_identifier = (value["identifier"] or '').strip()
normalized_identifier = normalize_pid(
value["identifier"], value["scheme"].lower()
Expand Down Expand Up @@ -57,4 +63,4 @@ def __call__(self, value):
datetime.strptime(value, "%Y-%m-%d")
return value
except:
return super().__call__(value)
return super().__call__(value)
2 changes: 1 addition & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[metadata]
name = oarepo-runtime
version = 1.5.88
version = 1.5.89
description = A set of runtime extensions of Invenio repository
authors = Alzbeta Pokorna
readme = README.md
Expand Down

0 comments on commit a6de941

Please sign in to comment.