aboutsummaryrefslogtreecommitdiffstats
path: root/rust/src
diff options
context:
space:
mode:
authorBryan Newbold <bnewbold@robocracy.org>2019-05-20 18:20:58 -0700
committerBryan Newbold <bnewbold@robocracy.org>2019-05-20 18:20:58 -0700
commitb53180fa0d283feca9e14a69437e7eaf1c0d96a4 (patch)
treeabdd3aa87d6fdbda51e8edf5dd6d7d4ff4aaec26 /rust/src
parentcd829eedb5bfc7328ab5266650a625a6c88db6fa (diff)
downloadfatcat-b53180fa0d283feca9e14a69437e7eaf1c0d96a4.tar.gz
fatcat-b53180fa0d283feca9e14a69437e7eaf1c0d96a4.zip
basic controlled vocabulary for withdrawn_stage
Diffstat (limited to 'rust/src')
-rw-r--r--rust/src/identifiers.rs40
1 files changed, 38 insertions, 2 deletions
diff --git a/rust/src/identifiers.rs b/rust/src/identifiers.rs
index 37305677..11fae56b 100644
--- a/rust/src/identifiers.rs
+++ b/rust/src/identifiers.rs
@@ -595,6 +595,44 @@ fn test_check_release_stage() {
assert!(check_release_stage("draft ").is_err());
}
+pub fn check_withdrawn_status(raw: &str) -> Result<()> {
+ let valid_types = vec![
+ // Didn't have a controlled vocab so made one up
+ "withdrawn", // generic
+ "retracted",
+ "concern",
+ "legal",
+ "safety",
+ "national-security",
+ "spam",
+
+ // potential more-specific statuses
+ //"author-misconduct",
+ //"author-mistake",
+ //"publisher-misconduct",
+ //"publisher-mistake",
+ //"unreliable",
+ ];
+ for good in valid_types {
+ if raw == good {
+ return Ok(());
+ }
+ }
+ Err(FatcatError::NotInControlledVocabulary(
+ "withdrawn_status (controlled vocabulary)".to_string(),
+ raw.to_string(),
+ ))?
+}
+
+#[test]
+fn test_check_withdrawn_status() {
+ assert!(check_withdrawn_status("legal").is_ok());
+ assert!(check_withdrawn_status("withdrawn").is_ok());
+ assert!(check_withdrawn_status("boondogle").is_err());
+ assert!(check_withdrawn_status("").is_err());
+ assert!(check_withdrawn_status("editor ").is_err());
+}
+
pub fn check_contrib_role(raw: &str) -> Result<()> {
let valid_types = vec![
// Citation Style Language official role types
@@ -635,5 +673,3 @@ fn test_check_contrib_role() {
assert!(check_contrib_role("editor ").is_err());
}
-// TODO: make the above checks "more correct"
-// TODO: check ISBN-13