diff options
Diffstat (limited to 'src/validation/category.rs')
-rw-r--r-- | src/validation/category.rs | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/src/validation/category.rs b/src/validation/category.rs new file mode 100644 index 0000000..7b1b5d5 --- /dev/null +++ b/src/validation/category.rs @@ -0,0 +1,18 @@ +use std::collections::HashMap; + +use crate::model::category::{Create, Update}; +use crate::validation::utils::*; + +pub fn create(form: &HashMap<String, String>) -> Option<Create> { + Some(Create { + name: non_empty(form, "name")?, + color: color(form, "color")?, + }) +} + +pub fn update(form: &HashMap<String, String>) -> Option<Update> { + Some(Update { + name: non_empty(form, "name")?, + color: color(form, "color")?, + }) +} |