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")?,
    })
}