summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatthias Beyer <mail@beyermatthias.de>2019-07-14 12:18:57 +0200
committerMatthias Beyer <mail@beyermatthias.de>2019-07-14 12:29:31 +0200
commitba77f5e8babfc25857587bfa5979700bacdb636d (patch)
treee0927115007c59d8b7edb5de3b6dd446b07d3ff6
parentce9fb3c37095fb3375ad799624443eb9842e11e5 (diff)
downloadimag-ba77f5e8babfc25857587bfa5979700bacdb636d.zip
imag-ba77f5e8babfc25857587bfa5979700bacdb636d.tar.gz
Add cli validators for date and datetime
-rw-r--r--lib/etc/libimagutil/src/cli_validators.rs8
1 files changed, 8 insertions, 0 deletions
diff --git a/lib/etc/libimagutil/src/cli_validators.rs b/lib/etc/libimagutil/src/cli_validators.rs
index 0288b08..e7510b1 100644
--- a/lib/etc/libimagutil/src/cli_validators.rs
+++ b/lib/etc/libimagutil/src/cli_validators.rs
@@ -61,3 +61,11 @@ pub fn is_url<A: AsRef<str>>(s: A) -> Result<(), String> {
Url::parse(s.as_ref()).map(|_| ()).map_err(|_| format!("Not a URL: {}", s.as_ref()))
}
+pub fn is_datetime<A: AsRef<str>>(s: A) -> Result<(), String> {
+ crate::date::datetime_from_string(s).map(|_| ()).map_err(|e| format!("{}", e))
+}
+
+pub fn is_date<A: AsRef<str>>(s: A) -> Result<(), String> {
+ crate::date::date_from_string(s).map(|_| ()).map_err(|e| format!("{}", e))
+}
+