Skip to article frontmatterSkip to article content
Site not loading correctly?

This may be due to an incorrect BASE_URL configuration. See the MyST Documentation for reference.

doi_validator.py - Validate and convert DOI links

Description

Validates DOI links and converts them between different formats. Specifically designed for Harvard Dataverse DOIs (10.7910/DVN prefix), extracting the dataset tag and determining the server URL from various input formats.

Usage

from doi_validator import doi_validate

# Call the validation function
result = doi_validate(doi_string)

This is a Python module designed to be imported and used in other scripts, not a standalone command-line tool.

Supported Input Formats

  1. Full DOI URL: https://doi.org/10.7910/DVN/JKFYMJ

  2. Dataverse URL: https://dataverse.harvard.edu/dataset.xhtml?persistentId=doi:10.7910/DVN/JKFYMJ

  3. Short DOI: 10.7910/DVN/JKFYMJ

Return Values

Example

from doi_validator import doi_validate

# Validate various formats
tag1 = doi_validate("https://doi.org/10.7910/DVN/JKFYMJ")
# Returns: "JKFYMJ"

tag2 = doi_validate("10.7910/DVN/AB123C")
# Returns: "AB123C"

tag3 = doi_validate("https://dataverse.harvard.edu/dataset.xhtml?persistentId=doi:10.7910/DVN/XY89ZW")
# Returns: "XY89ZW"

tag4 = doi_validate("invalid-doi")
# Returns: "invalid format"

Requirements

Validation Rules

Use Cases

See Also