aboutsummaryrefslogtreecommitdiff
path: root/src/validation/mod.rs
blob: 07a7c4c74bc90d113508cdf1b1458350c5a5811b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
use chrono::NaiveTime;

use crate::model::time;

pub fn time(time: String) -> Option<Option<NaiveTime>> {
    let time = time.trim();
    if time.is_empty() {
        Some(None)
    } else {
        time::parse(time).map(Some)
    }
}

pub fn non_empty(str: String) -> Option<String> {
    let str = str.trim();
    if str.is_empty() {
        None
    } else {
        Some(str.to_string())
    }
}