Skip to main content

entrenar/research/artifact/
mod.rs

1//! Research Artifact and Author structs (ENT-019)
2//!
3//! Provides core types for academic research artifacts with proper
4//! attribution using CRediT taxonomy, ORCID, and ROR identifiers.
5
6mod affiliation;
7mod artifact_type;
8mod author;
9mod error;
10mod license;
11mod research_artifact;
12mod role;
13
14#[cfg(test)]
15mod tests;
16
17use regex::Regex;
18use std::sync::LazyLock;
19
20pub use affiliation::Affiliation;
21pub use artifact_type::ArtifactType;
22pub use author::Author;
23pub use error::ValidationError;
24pub use license::License;
25pub use research_artifact::ResearchArtifact;
26pub use role::ContributorRole;
27
28/// ORCID validation pattern: 0000-0000-0000-000X
29static ORCID_REGEX: LazyLock<Regex> =
30    LazyLock::new(|| Regex::new(r"^(\d{4}-){3}\d{3}[\dX]$").expect("Invalid ORCID regex"));
31
32/// ROR ID validation pattern: https://ror.org/xxxxxxxxx
33static ROR_REGEX: LazyLock<Regex> =
34    LazyLock::new(|| Regex::new(r"^https://ror\.org/[a-z0-9]{9}$").expect("Invalid ROR regex"));
35
36/// Validate ORCID format: 0000-0000-0000-000X
37pub fn validate_orcid(orcid: &str) -> bool {
38    ORCID_REGEX.is_match(orcid)
39}
40
41/// Validate ROR ID format: <https://ror.org/xxxxxxxxx>
42pub fn validate_ror_id(ror_id: &str) -> bool {
43    ROR_REGEX.is_match(ror_id)
44}