summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatthias Beyer <mail@beyermatthias.de>2017-06-17 12:54:13 +0200
committerGitHub <noreply@github.com>2017-06-17 12:54:13 +0200
commit71e3d3d2d11219fdd1810c211708d8a321d45fa3 (patch)
tree6edd63670b927563835c3fa91d7e254dcef9875d
parentc4d4fe938937a2cb27d404fb1d026f234c50b9ac (diff)
parentac805dcef78e9f78bd968b06bda5650f2b87b9be (diff)
downloadimag-71e3d3d2d11219fdd1810c211708d8a321d45fa3.zip
imag-71e3d3d2d11219fdd1810c211708d8a321d45fa3.tar.gz
Merge pull request #968 from matthiasbeyer/libimagentrytag/validator-helper-enhancement
Add is_tag_str(&str) wrapper for is_tag(String)
-rw-r--r--libimagentrytag/src/tag.rs6
1 files changed, 5 insertions, 1 deletions
diff --git a/libimagentrytag/src/tag.rs b/libimagentrytag/src/tag.rs
index cf3d676..6cfcf1c 100644
--- a/libimagentrytag/src/tag.rs
+++ b/libimagentrytag/src/tag.rs
@@ -22,13 +22,17 @@ pub type TagSlice<'a> = &'a str;
/// validator which can be used by clap to validate that a string is a valid tag
pub fn is_tag(s: String) -> Result<(), String> {
+ is_tag_str(&s)
+}
+
+pub fn is_tag_str(s: &String) -> Result<(), String> {
use filters::filter::Filter;
let is_lower = |s: &String| s.chars().all(|c| c.is_lowercase());
let no_whitespace = |s: &String| s.chars().all(|c| !c.is_whitespace());
let is_alphanum = |s: &String| s.chars().all(|c| c.is_alphanumeric());
- if is_lower.and(no_whitespace).and(is_alphanum).filter(&s) {
+ if is_lower.and(no_whitespace).and(is_alphanum).filter(s) {
Ok(())
} else {
Err(format!("The string '{}' is not a valid tag", s))