diff --git a/CHANGELOG.md b/CHANGELOG.md index 654dc727..822a51f6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,8 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). ## [Unreleased] +### Fixed + - [500](https://github.com/thoth-pub/thoth/issues/500) - Update ORCID regex ## [[0.11.2]](https://github.com/thoth-pub/thoth/releases/tag/v0.11.2) - 2023-06-19 ### Changed diff --git a/thoth-api/migrations/0.11.3/down.sql b/thoth-api/migrations/0.11.3/down.sql new file mode 100644 index 00000000..6d21b774 --- /dev/null +++ b/thoth-api/migrations/0.11.3/down.sql @@ -0,0 +1,6 @@ +-- Reinstate earlier version of ORCID validation + +ALTER TABLE contributor + DROP CONSTRAINT contributor_orcid_check, + ADD CONSTRAINT contributor_orcid_check + CHECK (orcid ~ '^https:\/\/orcid\.org\/0000-000(1-[5-9]|2-[0-9]|3-[0-4])\d{3}-\d{3}[\dX]$'); diff --git a/thoth-api/migrations/0.11.3/up.sql b/thoth-api/migrations/0.11.3/up.sql new file mode 100644 index 00000000..e3662ebc --- /dev/null +++ b/thoth-api/migrations/0.11.3/up.sql @@ -0,0 +1,7 @@ +-- Make ORCID validation more permissive as the docs don't specify a strict pattern +-- Should be kept in line with Orcid::FromStr, although regex syntax differs slightly + +ALTER TABLE contributor + DROP CONSTRAINT contributor_orcid_check, + ADD CONSTRAINT contributor_orcid_check + CHECK (orcid ~ '^https:\/\/orcid\.org\/\d{4}-\d{4}-\d{4}-\d{3}[\dX]$'); diff --git a/thoth-api/src/graphql/model.rs b/thoth-api/src/graphql/model.rs index 05147206..6f608b9c 100644 --- a/thoth-api/src/graphql/model.rs +++ b/thoth-api/src/graphql/model.rs @@ -2349,7 +2349,7 @@ impl Work { } #[graphql( - description = "Indicates that the work contains a bibliogrpahy or other similar information" + description = "Indicates that the work contains a bibliography or other similar information" )] pub fn bibliography_note(&self) -> Option<&String> { self.bibliography_note.as_ref() diff --git a/thoth-api/src/model/mod.rs b/thoth-api/src/model/mod.rs index 21029e31..cc00bbe3 100644 --- a/thoth-api/src/model/mod.rs +++ b/thoth-api/src/model/mod.rs @@ -66,7 +66,7 @@ pub struct Isbn(String); feature = "backend", derive(DieselNewType, juniper::GraphQLScalarValue), graphql( - description = r#"ORCID (Open Researcher and Contributor ID) identifier. Expressed as `^https:\/\/orcid\.org\/0000-000(1-[5-9]|2-[0-9]|3-[0-4])\d{3}-\d{3}[\dX]$`"# + description = r#"ORCID (Open Researcher and Contributor ID) identifier. Expressed as `^https:\/\/orcid\.org\/\d{4}-\d{4}-\d{4}-\d{3}[\dX]$`"# ) )] #[derive(Debug, Clone, Default, Serialize, Deserialize, PartialEq, Eq)] @@ -193,10 +193,10 @@ impl FromStr for Orcid { // (?:) = non-capturing group // i = case-insensitive flag // $ = end of string - // Matches strings of format "[[http[s]://][www.]orcid.org/]0000-000X-XXXX-XXXX" + // Matches strings of format "[[http[s]://][www.]orcid.org/]XXXX-XXXX-XXXX-XXXX" // and captures the 16-digit identifier segment // Corresponds to database constraints although regex syntax differs slightly - r#"^(?i:(?:https?://)?(?:www\.)?orcid\.org/)?(0000-000(?:1-[5-9]|2-[0-9]|3-[0-4])\d{3}-\d{3}[\dX]$)"#).unwrap(); + r#"^(?i:(?:https?://)?(?:www\.)?orcid\.org/)?(\d{4}-\d{4}-\d{4}-\d{3}[\dX]$)"#).unwrap(); } if input.is_empty() { Err(ThothError::OrcidEmptyError) @@ -776,6 +776,7 @@ fn test_orcid_fromstr() { assert!(Orcid::from_str("//orcid.org/0000-0002-1234-5678").is_err()); assert!(Orcid::from_str("https://orcid-org/0000-0002-1234-5678").is_err()); assert!(Orcid::from_str("0000-0002-1234-5678https://orcid.org/").is_err()); + assert!(Orcid::from_str("0009-0002-1234-567X").is_ok()); } #[test] diff --git a/thoth-client/assets/schema.json b/thoth-client/assets/schema.json index a20030cf..a8302fb6 100644 --- a/thoth-client/assets/schema.json +++ b/thoth-client/assets/schema.json @@ -12250,7 +12250,7 @@ { "args": [], "deprecationReason": null, - "description": null, + "description": "A general-purpose field used to include information that does not have a specific designated field", "isDeprecated": false, "name": "generalNote", "type": { @@ -12262,7 +12262,7 @@ { "args": [], "deprecationReason": null, - "description": null, + "description": "Indicates that the work contains a bibliography or other similar information", "isDeprecated": false, "name": "bibliographyNote", "type": { @@ -22164,7 +22164,7 @@ "possibleTypes": null }, { - "description": "ORCID (Open Researcher and Contributor ID) identifier. Expressed as `^https:\\/\\/orcid\\.org\\/0000-000(1-[5-9]|2-[0-9]|3-[0-4])\\d{3}-\\d{3}[\\dX]$`", + "description": "ORCID (Open Researcher and Contributor ID) identifier. Expressed as `^https:\\/\\/orcid\\.org\\/\\d{4}-\\d{4}-\\d{4}-\\d{3}[\\dX]$`", "enumValues": null, "fields": null, "inputFields": null,