acorn_lib/
constants.rs

1use fancy_regex::Regex;
2use lazy_static::lazy_static;
3
4pub const DISCLAIMER: &str = "Oak Ridge National Laboratory is managed by UT-Batelle LLC for the US Department of Energy";
5/// Base URL for deploying ORNL data
6pub const BASE_URL: &str = "https://research.ornl.gov";
7// ORNL brand colors
8// https://www.olcf.ornl.gov/about-olcf/media-assets/
9pub const COLOR_TRANSPARENT: [u8; 4] = [255, 255, 255, 0];
10pub const COLOR_PRIMARY: [u8; 4] = [0, 121, 52, 255];
11// Vale
12pub const VALE_RELEASES_URL: &str = "https://github.com/errata-ai/vale/releases";
13pub const VALE_VERSION: &str = "3.9.4";
14// Project folder values
15pub const APPLICATION: &str = "acorn";
16pub const ORGANIZATION: &str = "ornl";
17pub const QUALIFIER: &str = "org";
18// Schema defaults
19pub const DEFAULT_AFFILIATION: &str = "Oak Ridge National Laboratory";
20pub const DEFAULT_GRAPHIC_HREF: &str = "00.png";
21pub const DEFAULT_GRAPHIC_CAPTION: &str = "";
22// Validation
23pub const MAX_COUNT_APPROACH: u64 = 6;
24/// Maxumum number of [capabilities](/acorn_lib/schema/struct.OrganizationSections.html#structfield.capabilities) for an [organization](/acorn_lib/schema/enum.SchemaType.html#variant.Organization)
25pub const MAX_COUNT_CAPABILITIES: u64 = 6;
26/// Maxumum number of [impact statements](/acorn_lib/schema/struct.ProjectSections.html#structfield.impact) for a [project](/acorn_lib/schema/enum.SchemaType.html#variant.Project)
27pub const MAX_COUNT_IMPACT: u64 = 6;
28/// Maximum number of [research areas](/acorn_lib/schema/struct.Research.html#structfield.areas)
29pub const MAX_COUNT_RESEARCH_AREAS: u64 = 4;
30/// Maximum number of characters for an approach statement
31pub const MAX_LENGTH_APPROACH: usize = 150;
32/// Maximum number of characters for a single [capability](/acorn_lib/schema/struct.OrganizationSections.html#structfield.capabilities) description
33pub const MAX_LENGTH_CAPABILIY: usize = 300;
34/// Maximum number of characters for a single facility description
35pub const MAX_LENGTH_FACILITY: usize = 50;
36/// Maximum number of characters for a single image caption
37pub const MAX_LENGTH_IMAGE_CAPTION: u64 = 100;
38/// Maximum number of characters for a single impact description
39pub const MAX_LENGTH_IMPACT: usize = 150;
40/// Maximum number of characters for a single [research area](/acorn_lib/schema/struct.Research.html#structfield.areas) description
41pub const MAX_LENGTH_RESEARCH_AREA: usize = 40;
42/// Maximum number of characters for an single [research focus](/acorn_lib/schema/struct.Research.html#structfield.focus) description
43pub const MAX_LENGTH_RESEARCH_FOCUS: u64 = 150;
44/// Maximum number of characters for an introduction section
45pub const MAX_LENGTH_SECTION_INTRODUCTION: u64 = 250;
46/// Maximum number of characters for a challenge section
47pub const MAX_LENGTH_SECTION_CHALLENGE: u64 = 500;
48/// Maximum number of characters for a subtitle
49pub const MAX_LENGTH_SUBTITLE: u64 = 75;
50/// Maximum number of characters for a single technical approach description
51pub const MAX_LENGTH_TECHNICAL: usize = 100;
52/// Maximum number of characters for a title
53pub const MAX_LENGTH_TITLE: u64 = 45;
54
55lazy_static! {
56    /// ### DOI
57    /// > Should match a Digital Object Identifier (DOI)
58    ///
59    /// See <https://www.doi.org/> for more information
60    pub static ref RE_DOI: Regex = Regex::new(r#"^(doi\:)?10\.\d+/.*$"#).unwrap();
61    /// ### ROR
62    /// > Should match a Research Organization Registry (ROR)
63    ///
64    /// See <https://www.ror.org/> for more information
65    pub static ref RE_ROR: Regex = Regex::new(r#"^0[a-hj-km-np-tv-z|0-9]{6}[0-9]{2}$"#).unwrap();
66    /// ### Should match an image extension (e.g. .png, .jpg, .jpeg, .svg)
67    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();
68    /// ### Should match an IP6 address
69    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();
70    /// ### Should match a phone number (with optional country and area codes)
71    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();
72    /// ### Should match a fake phone number (e.g. 555.555.5555)
73    pub static ref RE_FAKE_PHONE: Regex = Regex::new(r#"^(\+\d{1,2}\s?)?\(?5{3}\)?[\s.-]?5{3}[\s.-]?5{4}$"#).unwrap();
74}