diff options
author | jelemux <jeremias.weber@protonmail.com> | 2020-10-21 22:01:59 +0200 |
---|---|---|
committer | jelemux <jeremias.weber@protonmail.com> | 2020-10-21 22:01:59 +0200 |
commit | 10eb0e8cff7f0bc6b61a77a179fec55ee1dfe929 (patch) | |
tree | 7c3c3b4ed11e723fb5c55091af7d33440783f52b /excluded/validation.rs | |
parent | f267433455dbc69e771b06dd7c433c90ad978d33 (diff) | |
download | wasm-card-10eb0e8cff7f0bc6b61a77a179fec55ee1dfe929.tar.gz wasm-card-10eb0e8cff7f0bc6b61a77a179fec55ee1dfe929.tar.bz2 |
basic prototype with vcard and pdf generation
Diffstat (limited to 'excluded/validation.rs')
-rw-r--r-- | excluded/validation.rs | 37 |
1 files changed, 0 insertions, 37 deletions
diff --git a/excluded/validation.rs b/excluded/validation.rs deleted file mode 100644 index 6258dcf..0000000 --- a/excluded/validation.rs +++ /dev/null @@ -1,37 +0,0 @@ - - -pub trait Validation { - fn validate(&self) -> Result<(), ValidationError>; -} - -#[derive(Debug)] -pub struct ValidationError { - pub messages: Vec<String>, -} - -impl std::fmt::Display for ValidationError { - fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - for msg in &self.messages { - write!(f, "{}\n", msg)?; - } - Ok(()) - } -} - -impl std::error::Error for ValidationError { } - -pub fn add_results(first: Result<(), ValidationError>, second: Result<(), ValidationError>) -> Result<(), ValidationError> { - if first.is_ok() && second.is_ok() { - Ok(()) - } else if first.is_ok() && second.is_err() { - second - } else if first.is_err() && second.is_ok() { - first - } else { - let mut first = first.err().unwrap(); - let mut second = second.err().unwrap(); - first.messages.append(&mut second.messages); - - Err( ValidationError{ messages: first.messages } ) - } -}
\ No newline at end of file |