diff --git a/packages/fortifier/src/validations/email_address.rs b/packages/fortifier/src/validations/email_address.rs index b22c342..dd2f63e 100644 --- a/packages/fortifier/src/validations/email_address.rs +++ b/packages/fortifier/src/validations/email_address.rs @@ -1,6 +1,8 @@ use std::{ borrow::Cow, cell::{Ref, RefMut}, + error::Error, + fmt, rc::Rc, sync::Arc, }; @@ -197,6 +199,14 @@ pub enum EmailAddressError { }, } +impl fmt::Display for EmailAddressError { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + write!(f, "{self:#?}") + } +} + +impl Error for EmailAddressError {} + impl From for EmailAddressError { fn from(value: email_address::Error) -> Self { let code = EmailAddressErrorCode; diff --git a/packages/fortifier/src/validations/length.rs b/packages/fortifier/src/validations/length.rs index ed9b9dc..481279a 100644 --- a/packages/fortifier/src/validations/length.rs +++ b/packages/fortifier/src/validations/length.rs @@ -2,7 +2,8 @@ use std::{ borrow::Cow, cell::{Ref, RefMut}, collections::{BTreeMap, BTreeSet, HashMap, HashSet, LinkedList, VecDeque}, - fmt::Display, + error::Error, + fmt::{self, Debug, Display}, rc::Rc, sync::Arc, }; @@ -77,6 +78,14 @@ pub enum LengthError { }, } +impl fmt::Display for LengthError { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + write!(f, "{self:#?}") + } +} + +impl Error for LengthError {} + /// Validate a length. pub trait ValidateLength where diff --git a/packages/fortifier/src/validations/phone_number.rs b/packages/fortifier/src/validations/phone_number.rs index f105719..a1d7592 100644 --- a/packages/fortifier/src/validations/phone_number.rs +++ b/packages/fortifier/src/validations/phone_number.rs @@ -1,6 +1,8 @@ use std::{ borrow::Cow, cell::{Ref, RefMut}, + error::Error, + fmt, rc::Rc, sync::Arc, }; @@ -107,6 +109,14 @@ pub enum PhoneNumberError { }, } +impl fmt::Display for PhoneNumberError { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + write!(f, "{self:#?}") + } +} + +impl Error for PhoneNumberError {} + impl From for PhoneNumberError { fn from(value: ParseError) -> Self { let code = PhoneNumberErrorCode; diff --git a/packages/fortifier/src/validations/range.rs b/packages/fortifier/src/validations/range.rs index c185df4..7a0abca 100644 --- a/packages/fortifier/src/validations/range.rs +++ b/packages/fortifier/src/validations/range.rs @@ -1,6 +1,7 @@ use std::{ cell::{Ref, RefMut}, - fmt::Display, + error::Error, + fmt::{self, Debug, Display}, rc::Rc, sync::Arc, }; @@ -88,6 +89,14 @@ pub enum RangeError { }, } +impl fmt::Display for RangeError { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + write!(f, "{self:#?}") + } +} + +impl Error for RangeError {} + /// Validate a range. pub trait ValidateRange where diff --git a/packages/fortifier/src/validations/regex.rs b/packages/fortifier/src/validations/regex.rs index 2ec626b..7292ae4 100644 --- a/packages/fortifier/src/validations/regex.rs +++ b/packages/fortifier/src/validations/regex.rs @@ -1,6 +1,8 @@ use std::{ borrow::Cow, cell::{Ref, RefMut}, + error::Error, + fmt, rc::Rc, sync::{Arc, LazyLock}, }; @@ -67,6 +69,14 @@ impl Default for RegexError { } } +impl fmt::Display for RegexError { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + write!(f, "{self:#?}") + } +} + +impl Error for RegexError {} + /// Validate a regular expression. pub trait ValidateRegex { /// Validate regular expression. diff --git a/packages/fortifier/src/validations/url.rs b/packages/fortifier/src/validations/url.rs index 19836a0..e89b9f8 100644 --- a/packages/fortifier/src/validations/url.rs +++ b/packages/fortifier/src/validations/url.rs @@ -1,6 +1,8 @@ use std::{ borrow::Cow, cell::{Ref, RefMut}, + error::Error, + fmt, rc::Rc, sync::Arc, }; @@ -136,6 +138,14 @@ pub enum UrlError { }, } +impl fmt::Display for UrlError { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + write!(f, "{self:#?}") + } +} + +impl Error for UrlError {} + impl From for UrlError { fn from(value: ParseError) -> Self { let code = UrlErrorCode;