diff --git a/lib/etc/libimagutil/src/cli_validators.rs b/lib/etc/libimagutil/src/cli_validators.rs index e2e9c8a5..eb5cdd1e 100644 --- a/lib/etc/libimagutil/src/cli_validators.rs +++ b/lib/etc/libimagutil/src/cli_validators.rs @@ -42,6 +42,20 @@ pub fn is_integer>(s: A) -> Result<(), String> { i.map(|_| ()).map_err(|_| format!("Not an integer: {}", s.as_ref())) } +pub fn is_float>(s: A) -> Result<(), String> { + use std::str::FromStr; + + let i : Result = FromStr::from_str(s.as_ref()); + i.map(|_| ()).map_err(|_| format!("Not an float: {}", s.as_ref())) +} + +pub fn is_bool>(s: A) -> Result<(), String> { + use std::str::FromStr; + + let i : Result = FromStr::from_str(s.as_ref()); + i.map(|_| ()).map_err(|_| format!("Not an bool: {}", s.as_ref())) +} + pub fn is_url>(s: A) -> Result<(), String> { use url::Url; Url::parse(s.as_ref()).map(|_| ()).map_err(|_| format!("Not a URL: {}", s.as_ref()))