From 35cc74578e969bae4812afd2ff041eba3746142d Mon Sep 17 00:00:00 2001 From: Joris Date: Sat, 19 Mar 2022 22:03:58 +0100 Subject: Allow to repeat an event until a specific date Also provide a shortcut to modify a repetead event from a specific occurence. This set the end repetition date under the hood and create a new repeated event. --- src/validation/mod.rs | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 src/validation/mod.rs (limited to 'src/validation') diff --git a/src/validation/mod.rs b/src/validation/mod.rs new file mode 100644 index 0000000..07a7c4c --- /dev/null +++ b/src/validation/mod.rs @@ -0,0 +1,21 @@ +use chrono::NaiveTime; + +use crate::model::time; + +pub fn time(time: String) -> Option> { + let time = time.trim(); + if time.is_empty() { + Some(None) + } else { + time::parse(time).map(Some) + } +} + +pub fn non_empty(str: String) -> Option { + let str = str.trim(); + if str.is_empty() { + None + } else { + Some(str.to_string()) + } +} -- cgit v1.2.3