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
23/// Maxumum number of [capabilities](/acorn_lib/schema/struct.OrganizationSections.html#structfield.capabilities) for an [organization](/acorn_lib/schema/enum.SchemaType.html#variant.Organization)
24pub const MAX_COUNT_CAPABILITIES: u64 = 6;
25/// Maxumum number of [outcomes](/acorn_lib/schema/struct.ProjectSections.html#structfield.outcomes) for a [project](/acorn_lib/schema/enum.SchemaType.html#variant.Project)
26pub const MAX_COUNT_OUTCOMES: u64 = 6;
27/// Maximum number of [research areas](/acorn_lib/schema/struct.Research.html#structfield.areas)
28pub const MAX_COUNT_RESEARCH_AREAS: u64 = 4;
29/// Maximum number of characters for a single [capability](/acorn_lib/schema/struct.OrganizationSections.html#structfield.capabilities) description
30pub const MAX_LENGTH_CAPABILIY: usize = 300;
31/// Maximum number of characters for a single facility description
32pub const MAX_LENGTH_FACILITY: usize = 50;
33/// Maximum number of characters for a single graphic caption
34pub const MAX_LENGTH_GRAPHIC_CAPTION: u64 = 100;
35/// Maximum number of characters for a single impact description
36pub const MAX_LENGTH_IMPACT: usize = 400;
37/// Maximum number of characters for a single [outcome](/acorn_lib/schema/struct.ProjectSections.html#structfield.outcomes) description
38pub const MAX_LENGTH_OUTCOME: usize = 150;
39/// Maximum number of characters for a single [research area](/acorn_lib/schema/struct.Research.html#structfield.areas) description
40pub const MAX_LENGTH_RESEARCH_AREA: usize = 40;
41/// Maximum number of characters for an single [research focus](/acorn_lib/schema/struct.Research.html#structfield.focus) description
42pub const MAX_LENGTH_RESEARCH_FOCUS: u64 = 150;
43/// Maximum number of characters for an introduction section
44pub const MAX_LENGTH_SECTION_INTRODUCTION: u64 = 250;
45/// Maximum number of characters for a challenge section
46pub const MAX_LENGTH_SECTION_CHALLENGE: u64 = 500;
47/// Maximum number of characters for an approach section
48pub const MAX_LENGTH_SECTION_APPROACH: u64 = 500;
49/// Maximum number of characters for a subtitle
50pub const MAX_LENGTH_SUBTITLE: u64 = 75;
51/// Maximum number of characters for a single technical approach description
52pub const MAX_LENGTH_TECHNICAL: usize = 100;
53/// Maximum number of characters for a title
54pub const MAX_LENGTH_TITLE: u64 = 45;
55
56lazy_static! {
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    /// ### Should match a Research Organization Registry (ROR)
62    ///
63    /// See <https://www.ror.org/> for more information
64    pub static ref RE_ROR: Regex = Regex::new(r#"^0[a-hj-km-np-tv-z|0-9]{6}[0-9]{2}$"#).unwrap();
65    /// ### Should match an image extension (e.g. .png, .jpg, .jpeg, .svg)
66    pub static ref RE_IMAGE_EXTENSION: Regex = Regex::new(r#".*[.](png|PNG|jpg|JPG|jpeg|JPEG|svg|SVG)$"#).unwrap();
67    /// ### Should match an IP6 address
68    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();
69    /// ### Should match a phone number (with optional country and area codes)
70    pub static ref RE_PHONE: Regex = Regex::new(r#"^(\+\d{1,2}\s?)?\(?\d{3}\)?[\s.-]?\d{3}[\s.-]?\d{4}$"#).unwrap();
71}