Loading Cargo.lock +4 −3 Original line number Diff line number Diff line Loading @@ -41,6 +41,7 @@ dependencies = [ "aho-corasick", "bat", "bon", "chrono", "clap", "color-eyre", "comfy-table", Loading Loading @@ -584,9 +585,9 @@ checksum = "613afe47fcd5fac7ccf1db93babcb082c5994d996f20b8b159f2ad1658eb5724" [[package]] name = "chrono" version = "0.4.39" version = "0.4.41" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7e36cc9d416881d2e24f9a963be5fb1cd90966419ac844274161d10488b3e825" checksum = "c469d952047f47f91b68d1cba3f10d63c11d73e4636f24f08daf0278abf01c4d" dependencies = [ "android-tzdata", "iana-time-zone", Loading @@ -594,7 +595,7 @@ dependencies = [ "num-traits", "serde", "wasm-bindgen", "windows-targets 0.52.6", "windows-link", ] [[package]] Loading acorn-lib/Cargo.toml +1 −0 Original line number Diff line number Diff line Loading @@ -24,6 +24,7 @@ maintenance = { status = "actively-developed" } aho-corasick = "1.1.3" bat = "0.25.0" bon = "3.3.2" chrono = { version = "0.4.41", features = ["serde"] } clap = { version = "4.4.2", features = ["derive", "unstable-doc"] } comfy-table = "7.1.4" console = { version = "0.16.0", features = ["ansi-parsing"] } Loading acorn-lib/src/constants.rs +8 −0 Original line number Diff line number Diff line Loading @@ -116,6 +116,14 @@ lazy_static! { pub static ref RE_IMAGE_EXTENSION: Regex = Regex::new(r#".*[.](png|PNG|jpg|JPG|jpeg|JPEG|svg|SVG|gif|GIF|webp|WEBP|tiff|TIFF)$"#).unwrap(); /// Regex that should match an IP6 address pub static ref RE_IP6: Regex = Regex::new(r#"(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))"#).unwrap(); /// Regex that should match an ISO 8601 date (e.g., `YYYY-MM-DD`) /// ### Example /// > `2025-06-04` pub static ref RE_ISO_8601_DATE: Regex = Regex::new(r#"^(?<year>(19[5-9][0-9]|20[0-2][0-9]))-(?<month>(((0[13578]|(10|12)))-(?<day>(0[1-9]|[1-2][0-9]|3[0-1]))|(02-(0[1-9]|[1-2][0-9]))|((0[469]|11)-(0[1-9]|[1-2][0-9]|30))))$"#).unwrap(); /// Regex that should match an ISO 8601 year from modern times, 1950 through 2029 /// ### Example /// > `2025` pub static ref RE_ISO_8601_YEAR: Regex = Regex::new(r#"^(?<year>(19[5-9][0-9]|20[0-2][0-9]))$"#).unwrap(); /// Regex that should match a phone number (with optional country and area codes) pub static ref RE_PHONE: Regex = Regex::new(r#"^(?<country>\+\d{1,2}\s?)?(?<area>\(?\d{3}\)?)[\s.-]?(?<prefix>\d{3})[\s.-]?(?<line>\d{4})$"#).unwrap(); /// Regex that should match a fake phone number (e.g. 555.555.5555) Loading acorn-lib/src/schema/mod.rs +5 −3 Original line number Diff line number Diff line Loading @@ -345,17 +345,19 @@ pub struct Metadata { /// Digital Object Identifier(s) related to the associated research activity data /// /// See <https://www.doi.org/> for more information #[validate(custom(function = "validate_attribute_doi"))] #[serde(default)] pub doi: Option<Vec<String>>, /// URL(s) of internet location where associated publication(s) can be found #[validate(custom(function = "is_list_url"))] #[serde(default)] pub publications: Option<Vec<String>>, /// Research Activity Identifier /// /// See <https://www.raid.org/> for more information #[validate(custom(function = "is_raid"))] #[serde(default, deserialize_with = "option_string_trim")] pub raid: Option<String>, #[validate(nested)] #[serde(default)] pub raid: Option<raid::Metadata>, /// Research Organization Registry /// /// See <https://www.ror.org/> for more information Loading acorn-lib/src/schema/raid.rs +8 −2 Original line number Diff line number Diff line Loading @@ -3,7 +3,7 @@ //! See <https://metadata.raid.org/en/v1.6/index.html> for official documentation on schema. //! //! Use ACORN to generate JSON schema for RAiD metadata with `acorn schema --raid` use crate::schema::validate::{is_raid, is_ror}; use crate::schema::validate::{is_iso8601_date, is_iso8601_year, is_raid, is_ror}; use crate::{License, SemanticVersion}; use bon::{builder, Builder}; use derive_more::Display; Loading Loading @@ -319,6 +319,7 @@ pub struct Access { /// <div class="warning">Embargo expiration dates may not lay more than 18 months from the date the RAiD was registered. Year, month, and day mush be specified.</div> /// /// [ISO 8601]: https://en.wikipedia.org/wiki/ISO_8601 #[validate(custom(function = "is_iso8601_date"))] pub embargo_expiry: Option<String>, /// Access statement /// Loading Loading @@ -430,12 +431,14 @@ pub struct Date { /// > [ISO 8601] standard date (e.g., `YYYY-MM-DD`) /// /// [ISO 8601]: https://en.wikipedia.org/wiki/ISO_8601 #[validate(custom(function = "is_iso8601_date"))] pub start_date: String, /// Associated data end date /// ### Format /// > [ISO 8601] standard date (e.g., `YYYY-MM-DD`) /// /// [ISO 8601]: https://en.wikipedia.org/wiki/ISO_8601 #[validate(custom(function = "is_iso8601_date"))] pub end_date: Option<String>, } /// Metadata schema block containing the description of the RAiD and associated properties Loading Loading @@ -580,7 +583,7 @@ pub struct Organization { /// URI of the organization identifier schema /// /// Only allowed value: `https://ror.org/` #[validate(url)] #[validate(url, contains(pattern = "https://ror.org"))] pub schema_uri: String, /// Organization role #[validate(nested)] Loading Loading @@ -749,6 +752,7 @@ pub struct Title { /// > [ISO 8601] standard date (e.g., `YYYY-MM-DD`) /// /// [ISO 8601]: https://en.wikipedia.org/wiki/ISO_8601 #[validate(custom(function = "is_iso8601_date"))] pub start_date: String, /// Date the project or activity title was changed or stopped being used /// ### Format Loading @@ -759,6 +763,8 @@ pub struct Title { /// <div class="warning">Listed as "recommended" (optional) and "required"</div> /// /// [ISO 8601]: https://en.wikipedia.org/wiki/ISO_8601 // TODO: Add support for month and day(?) #[validate(custom(function = "is_iso8601_year"))] pub end_date: String, } /// Metadata schema block containing information about the title type Loading Loading
Cargo.lock +4 −3 Original line number Diff line number Diff line Loading @@ -41,6 +41,7 @@ dependencies = [ "aho-corasick", "bat", "bon", "chrono", "clap", "color-eyre", "comfy-table", Loading Loading @@ -584,9 +585,9 @@ checksum = "613afe47fcd5fac7ccf1db93babcb082c5994d996f20b8b159f2ad1658eb5724" [[package]] name = "chrono" version = "0.4.39" version = "0.4.41" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7e36cc9d416881d2e24f9a963be5fb1cd90966419ac844274161d10488b3e825" checksum = "c469d952047f47f91b68d1cba3f10d63c11d73e4636f24f08daf0278abf01c4d" dependencies = [ "android-tzdata", "iana-time-zone", Loading @@ -594,7 +595,7 @@ dependencies = [ "num-traits", "serde", "wasm-bindgen", "windows-targets 0.52.6", "windows-link", ] [[package]] Loading
acorn-lib/Cargo.toml +1 −0 Original line number Diff line number Diff line Loading @@ -24,6 +24,7 @@ maintenance = { status = "actively-developed" } aho-corasick = "1.1.3" bat = "0.25.0" bon = "3.3.2" chrono = { version = "0.4.41", features = ["serde"] } clap = { version = "4.4.2", features = ["derive", "unstable-doc"] } comfy-table = "7.1.4" console = { version = "0.16.0", features = ["ansi-parsing"] } Loading
acorn-lib/src/constants.rs +8 −0 Original line number Diff line number Diff line Loading @@ -116,6 +116,14 @@ lazy_static! { pub static ref RE_IMAGE_EXTENSION: Regex = Regex::new(r#".*[.](png|PNG|jpg|JPG|jpeg|JPEG|svg|SVG|gif|GIF|webp|WEBP|tiff|TIFF)$"#).unwrap(); /// Regex that should match an IP6 address pub static ref RE_IP6: Regex = Regex::new(r#"(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))"#).unwrap(); /// Regex that should match an ISO 8601 date (e.g., `YYYY-MM-DD`) /// ### Example /// > `2025-06-04` pub static ref RE_ISO_8601_DATE: Regex = Regex::new(r#"^(?<year>(19[5-9][0-9]|20[0-2][0-9]))-(?<month>(((0[13578]|(10|12)))-(?<day>(0[1-9]|[1-2][0-9]|3[0-1]))|(02-(0[1-9]|[1-2][0-9]))|((0[469]|11)-(0[1-9]|[1-2][0-9]|30))))$"#).unwrap(); /// Regex that should match an ISO 8601 year from modern times, 1950 through 2029 /// ### Example /// > `2025` pub static ref RE_ISO_8601_YEAR: Regex = Regex::new(r#"^(?<year>(19[5-9][0-9]|20[0-2][0-9]))$"#).unwrap(); /// Regex that should match a phone number (with optional country and area codes) pub static ref RE_PHONE: Regex = Regex::new(r#"^(?<country>\+\d{1,2}\s?)?(?<area>\(?\d{3}\)?)[\s.-]?(?<prefix>\d{3})[\s.-]?(?<line>\d{4})$"#).unwrap(); /// Regex that should match a fake phone number (e.g. 555.555.5555) Loading
acorn-lib/src/schema/mod.rs +5 −3 Original line number Diff line number Diff line Loading @@ -345,17 +345,19 @@ pub struct Metadata { /// Digital Object Identifier(s) related to the associated research activity data /// /// See <https://www.doi.org/> for more information #[validate(custom(function = "validate_attribute_doi"))] #[serde(default)] pub doi: Option<Vec<String>>, /// URL(s) of internet location where associated publication(s) can be found #[validate(custom(function = "is_list_url"))] #[serde(default)] pub publications: Option<Vec<String>>, /// Research Activity Identifier /// /// See <https://www.raid.org/> for more information #[validate(custom(function = "is_raid"))] #[serde(default, deserialize_with = "option_string_trim")] pub raid: Option<String>, #[validate(nested)] #[serde(default)] pub raid: Option<raid::Metadata>, /// Research Organization Registry /// /// See <https://www.ror.org/> for more information Loading
acorn-lib/src/schema/raid.rs +8 −2 Original line number Diff line number Diff line Loading @@ -3,7 +3,7 @@ //! See <https://metadata.raid.org/en/v1.6/index.html> for official documentation on schema. //! //! Use ACORN to generate JSON schema for RAiD metadata with `acorn schema --raid` use crate::schema::validate::{is_raid, is_ror}; use crate::schema::validate::{is_iso8601_date, is_iso8601_year, is_raid, is_ror}; use crate::{License, SemanticVersion}; use bon::{builder, Builder}; use derive_more::Display; Loading Loading @@ -319,6 +319,7 @@ pub struct Access { /// <div class="warning">Embargo expiration dates may not lay more than 18 months from the date the RAiD was registered. Year, month, and day mush be specified.</div> /// /// [ISO 8601]: https://en.wikipedia.org/wiki/ISO_8601 #[validate(custom(function = "is_iso8601_date"))] pub embargo_expiry: Option<String>, /// Access statement /// Loading Loading @@ -430,12 +431,14 @@ pub struct Date { /// > [ISO 8601] standard date (e.g., `YYYY-MM-DD`) /// /// [ISO 8601]: https://en.wikipedia.org/wiki/ISO_8601 #[validate(custom(function = "is_iso8601_date"))] pub start_date: String, /// Associated data end date /// ### Format /// > [ISO 8601] standard date (e.g., `YYYY-MM-DD`) /// /// [ISO 8601]: https://en.wikipedia.org/wiki/ISO_8601 #[validate(custom(function = "is_iso8601_date"))] pub end_date: Option<String>, } /// Metadata schema block containing the description of the RAiD and associated properties Loading Loading @@ -580,7 +583,7 @@ pub struct Organization { /// URI of the organization identifier schema /// /// Only allowed value: `https://ror.org/` #[validate(url)] #[validate(url, contains(pattern = "https://ror.org"))] pub schema_uri: String, /// Organization role #[validate(nested)] Loading Loading @@ -749,6 +752,7 @@ pub struct Title { /// > [ISO 8601] standard date (e.g., `YYYY-MM-DD`) /// /// [ISO 8601]: https://en.wikipedia.org/wiki/ISO_8601 #[validate(custom(function = "is_iso8601_date"))] pub start_date: String, /// Date the project or activity title was changed or stopped being used /// ### Format Loading @@ -759,6 +763,8 @@ pub struct Title { /// <div class="warning">Listed as "recommended" (optional) and "required"</div> /// /// [ISO 8601]: https://en.wikipedia.org/wiki/ISO_8601 // TODO: Add support for month and day(?) #[validate(custom(function = "is_iso8601_year"))] pub end_date: String, } /// Metadata schema block containing information about the title type Loading