diff options
Diffstat (limited to 'src/validation/income.rs')
-rw-r--r-- | src/validation/income.rs | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/src/validation/income.rs b/src/validation/income.rs new file mode 100644 index 0000000..972e42a --- /dev/null +++ b/src/validation/income.rs @@ -0,0 +1,22 @@ +use std::collections::HashMap; + +use crate::model::income::{Create, Update}; +use crate::validation::utils::*; + +pub fn create(form: &HashMap<String, String>) -> Option<Create> { + Some(Create { + user_id: parse::<i64>(form, "user_id")?, + amount: parse::<i64>(form, "amount")?, + month: parse::<u32>(form, "month")?, + year: parse::<i32>(form, "year")?, + }) +} + +pub fn update(form: &HashMap<String, String>) -> Option<Update> { + Some(Update { + user_id: parse::<i64>(form, "user_id")?, + amount: parse::<i64>(form, "amount")?, + month: parse::<u32>(form, "month")?, + year: parse::<i32>(form, "year")?, + }) +} |