validatornator 0.4.0

A simple validator intended to be used value object constructors
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
use crate::utils::validation_error::ValidationError;

pub type ValidationResult<T> = Result<T, ValidationError>;

pub(crate) trait ValidationResultValue<T> {
    fn get(&self) -> Option<&T>;
}

impl<T> ValidationResultValue<T> for ValidationResult<T> {
    fn get(&self) -> Option<&T> {
        match self {
            Ok(value) => Some(value),
            Err(_) => panic!("Cannot get the value of an error result.")
        }
    }
}