diff options
author | Joris | 2021-01-03 13:40:40 +0100 |
---|---|---|
committer | Joris | 2021-01-03 13:54:20 +0100 |
commit | 11052951b74b9ad4b6a9412ae490086235f9154b (patch) | |
tree | 64526ac926c1bf470ea113f6cac8a33158684e8d /src/validation/income.rs | |
parent | 371449b0e312a03162b78797b83dee9d81706669 (diff) |
Rewrite in Rust
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")?, + }) +} |