iron_valid 0.4.1

Request validation library for iron, based on Laravel's validation
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
use params::{Map, Value};

pub fn validate_present(values: &Map, field: &str) -> Result<Option<Value>, String> {
    match values.find(&[field]) {
        Some(&Value::Null) |
        None => {
            Err(format!("The {} field must be present.",
                        field.to_lowercase().replace("_", " ")))
        }
        _ => Ok(None),
    }
}