Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 10 additions & 16 deletions packages/fortifier/src/validations/email_address.rs
Original file line number Diff line number Diff line change
Expand Up @@ -460,13 +460,10 @@ mod tests {
);

assert_eq!((&"admin@localhost").validate_email_address(options), Ok(()));
#[expect(unused_allocation)]
{
assert_eq!(
Box::new("admin@localhost").validate_email_address(options),
Ok(())
);
}
assert_eq!(
Box::new("admin@localhost").validate_email_address(options),
Ok(())
);
assert_eq!(
Arc::new("admin@localhost").validate_email_address(options),
Ok(())
Expand Down Expand Up @@ -535,15 +532,12 @@ mod tests {
email_address::Error::MissingSeparator
))
);
#[expect(unused_allocation)]
{
assert_eq!(
Box::new("admin").validate_email_address(options),
Err(EmailAddressError::from(
email_address::Error::MissingSeparator
))
);
}
assert_eq!(
Box::new("admin").validate_email_address(options),
Err(EmailAddressError::from(
email_address::Error::MissingSeparator
))
);
assert_eq!(
Arc::new("admin").validate_email_address(options),
Err(EmailAddressError::from(
Expand Down
74 changes: 31 additions & 43 deletions packages/fortifier/src/validations/length.rs
Original file line number Diff line number Diff line change
Expand Up @@ -320,10 +320,7 @@ mod tests {
}

assert_eq!((&"a").validate_length(Some(1), None, None), Ok(()));
#[expect(unused_allocation)]
{
assert_eq!(Box::new("a").validate_length(Some(1), None, None), Ok(()));
}
assert_eq!(Box::new("a").validate_length(Some(1), None, None), Ok(()));
assert_eq!(Arc::new("a").validate_length(Some(1), None, None), Ok(()));
assert_eq!(Rc::new("a").validate_length(Some(1), None, None), Ok(()));

Expand Down Expand Up @@ -514,19 +511,16 @@ mod tests {
message: "length 1 is not equal to required length 2".to_owned(),
})
);
#[expect(unused_allocation)]
{
assert_eq!(
Box::new("a").validate_length(Some(2), None, None),
Err(LengthError::Equal {
equal: 2,
value: 1,
code: LengthErrorCode,
#[cfg(feature = "message")]
message: "length 1 is not equal to required length 2".to_owned(),
})
);
}
assert_eq!(
Box::new("a").validate_length(Some(2), None, None),
Err(LengthError::Equal {
equal: 2,
value: 1,
code: LengthErrorCode,
#[cfg(feature = "message")]
message: "length 1 is not equal to required length 2".to_owned(),
})
);
assert_eq!(
Arc::new("a").validate_length(Some(2), None, None),
Err(LengthError::Equal {
Expand Down Expand Up @@ -750,19 +744,16 @@ mod tests {
message: "length 1 is less than minimum length 3".to_owned(),
})
);
#[expect(unused_allocation)]
{
assert_eq!(
Box::new("a").validate_length(None, Some(3), None),
Err(LengthError::Min {
min: 3,
value: 1,
code: LengthErrorCode,
#[cfg(feature = "message")]
message: "length 1 is less than minimum length 3".to_owned(),
})
);
}
assert_eq!(
Box::new("a").validate_length(None, Some(3), None),
Err(LengthError::Min {
min: 3,
value: 1,
code: LengthErrorCode,
#[cfg(feature = "message")]
message: "length 1 is less than minimum length 3".to_owned(),
})
);
assert_eq!(
Arc::new("a").validate_length(None, Some(3), None),
Err(LengthError::Min {
Expand Down Expand Up @@ -986,19 +977,16 @@ mod tests {
message: "length 1 is greater than maximum length 0".to_owned(),
})
);
#[expect(unused_allocation)]
{
assert_eq!(
Box::new("a").validate_length(None, None, Some(0)),
Err(LengthError::Max {
max: 0,
value: 1,
code: LengthErrorCode,
#[cfg(feature = "message")]
message: "length 1 is greater than maximum length 0".to_owned(),
})
);
}
assert_eq!(
Box::new("a").validate_length(None, None, Some(0)),
Err(LengthError::Max {
max: 0,
value: 1,
code: LengthErrorCode,
#[cfg(feature = "message")]
message: "length 1 is greater than maximum length 0".to_owned(),
})
);
assert_eq!(
Arc::new("a").validate_length(None, None, Some(0)),
Err(LengthError::Max {
Expand Down
22 changes: 8 additions & 14 deletions packages/fortifier/src/validations/phone_number.rs
Original file line number Diff line number Diff line change
Expand Up @@ -347,13 +347,10 @@ mod tests {
(&"+44 20 7946 0000").validate_phone_number(None, None),
Ok(())
);
#[expect(unused_allocation)]
{
assert_eq!(
Box::new("+44 20 7946 0000").validate_phone_number(None, None),
Ok(())
);
}
assert_eq!(
Box::new("+44 20 7946 0000").validate_phone_number(None, None),
Ok(())
);
assert_eq!(
Arc::new("+44 20 7946 0000").validate_phone_number(None, None),
Ok(())
Expand Down Expand Up @@ -400,13 +397,10 @@ mod tests {
(&"+44").validate_phone_number(None, None),
Err(PhoneNumberError::from(ParseError::NoNumber))
);
#[expect(unused_allocation)]
{
assert_eq!(
Box::new("+44").validate_phone_number(None, None),
Err(PhoneNumberError::from(ParseError::NoNumber))
);
}
assert_eq!(
Box::new("+44").validate_phone_number(None, None),
Err(PhoneNumberError::from(ParseError::NoNumber))
);
assert_eq!(
Arc::new("+44").validate_phone_number(None, None),
Err(PhoneNumberError::from(ParseError::NoNumber))
Expand Down
105 changes: 44 additions & 61 deletions packages/fortifier/src/validations/range.rs
Original file line number Diff line number Diff line change
Expand Up @@ -414,13 +414,10 @@ mod tests {
{
assert_eq!((&3).validate_range(Some(1), None, None, None), Ok(()));
}
#[expect(unused_allocation)]
{
assert_eq!(
(Box::new(3)).validate_range(Some(1), None, None, None),
Ok(())
);
}
assert_eq!(
(Box::new(3)).validate_range(Some(1), None, None, None),
Ok(())
);
assert_eq!(
(Arc::new(3)).validate_range(Some(1), None, None, None),
Ok(())
Expand Down Expand Up @@ -796,19 +793,16 @@ mod tests {
})
);
}
#[expect(unused_allocation)]
{
assert_eq!(
(Box::new(3)).validate_range(Some(4), None, None, None),
Err(RangeError::Min {
min: 4,
value: 3,
code: RangeErrorCode,
#[cfg(feature = "message")]
message: "value 3 is less than minimum value 4".to_owned(),
})
);
}
assert_eq!(
(Box::new(3)).validate_range(Some(4), None, None, None),
Err(RangeError::Min {
min: 4,
value: 3,
code: RangeErrorCode,
#[cfg(feature = "message")]
message: "value 3 is less than minimum value 4".to_owned(),
})
);
assert_eq!(
(Arc::new(3)).validate_range(Some(4), None, None, None),
Err(RangeError::Min {
Expand Down Expand Up @@ -1202,19 +1196,16 @@ mod tests {
})
);
}
#[expect(unused_allocation)]
{
assert_eq!(
(Box::new(3)).validate_range(None, Some(2), None, None),
Err(RangeError::Max {
max: 2,
value: 3,
code: RangeErrorCode,
#[cfg(feature = "message")]
message: "value 3 is greater than maximum value 2".to_owned(),
})
);
}
assert_eq!(
(Box::new(3)).validate_range(None, Some(2), None, None),
Err(RangeError::Max {
max: 2,
value: 3,
code: RangeErrorCode,
#[cfg(feature = "message")]
message: "value 3 is greater than maximum value 2".to_owned(),
})
);
assert_eq!(
(Arc::new(3)).validate_range(None, Some(2), None, None),
Err(RangeError::Max {
Expand Down Expand Up @@ -1615,20 +1606,16 @@ mod tests {
})
);
}
#[expect(unused_allocation)]
{
assert_eq!(
(Box::new(3)).validate_range(None, None, Some(3), None),
Err(RangeError::ExclusiveMin {
exclusive_min: 3,
value: 3,
code: RangeErrorCode,
#[cfg(feature = "message")]
message: "value 3 is less than or equal to exclusive minimum value 3"
.to_owned(),
})
);
}
assert_eq!(
(Box::new(3)).validate_range(None, None, Some(3), None),
Err(RangeError::ExclusiveMin {
exclusive_min: 3,
value: 3,
code: RangeErrorCode,
#[cfg(feature = "message")]
message: "value 3 is less than or equal to exclusive minimum value 3".to_owned(),
})
);
assert_eq!(
(Arc::new(3)).validate_range(None, None, Some(3), None),
Err(RangeError::ExclusiveMin {
Expand Down Expand Up @@ -2031,20 +2018,16 @@ mod tests {
})
);
}
#[expect(unused_allocation)]
{
assert_eq!(
(Box::new(3)).validate_range(None, None, None, Some(3)),
Err(RangeError::ExclusiveMax {
exclusive_max: 3,
value: 3,
code: RangeErrorCode,
#[cfg(feature = "message")]
message: "value 3 is greater than or equal to exclusive maximum value 3"
.to_owned(),
})
);
}
assert_eq!(
(Box::new(3)).validate_range(None, None, None, Some(3)),
Err(RangeError::ExclusiveMax {
exclusive_max: 3,
value: 3,
code: RangeErrorCode,
#[cfg(feature = "message")]
message: "value 3 is greater than or equal to exclusive maximum value 3".to_owned(),
})
);
assert_eq!(
(Arc::new(3)).validate_range(None, None, None, Some(3)),
Err(RangeError::ExclusiveMax {
Expand Down
24 changes: 9 additions & 15 deletions packages/fortifier/src/validations/regex.rs
Original file line number Diff line number Diff line change
Expand Up @@ -188,10 +188,7 @@ mod tests {
assert_eq!(Some("1234").validate_regex(&REGEX), Ok(()));

assert_eq!((&"1234").validate_regex(&REGEX), Ok(()));
#[expect(unused_allocation)]
{
assert_eq!(Box::new("1234").validate_regex(&REGEX), Ok(()));
}
assert_eq!(Box::new("1234").validate_regex(&REGEX), Ok(()));
assert_eq!(Arc::new("1234").validate_regex(&REGEX), Ok(()));
assert_eq!(Rc::new("1234").validate_regex(&REGEX), Ok(()));

Expand Down Expand Up @@ -223,17 +220,14 @@ mod tests {
);

assert_eq!((&"123").validate_regex(&REGEX), Err(RegexError::default()));
#[expect(unused_allocation)]
{
assert_eq!(
Box::new("123").validate_regex(&REGEX),
Err(RegexError {
code: RegexErrorCode,
#[cfg(feature = "message")]
message: "value does not match regular expression".to_owned(),
})
);
}
assert_eq!(
Box::new("123").validate_regex(&REGEX),
Err(RegexError {
code: RegexErrorCode,
#[cfg(feature = "message")]
message: "value does not match regular expression".to_owned(),
})
);
assert_eq!(
Arc::new("123").validate_regex(&REGEX),
Err(RegexError::default())
Expand Down
24 changes: 9 additions & 15 deletions packages/fortifier/src/validations/url.rs
Original file line number Diff line number Diff line change
Expand Up @@ -353,10 +353,7 @@ mod tests {
assert_eq!(Some("http://localhost").validate_url(), Ok(()));

assert_eq!((&"http://localhost").validate_url(), Ok(()));
#[expect(unused_allocation)]
{
assert_eq!(Box::new("http://localhost").validate_url(), Ok(()));
}
assert_eq!(Box::new("http://localhost").validate_url(), Ok(()));
assert_eq!(Arc::new("http://localhost").validate_url(), Ok(()));
assert_eq!(Rc::new("http://localhost").validate_url(), Ok(()));

Expand Down Expand Up @@ -397,17 +394,14 @@ mod tests {
(&"http://").validate_url(),
Err(UrlError::from(ParseError::EmptyHost))
);
#[expect(unused_allocation)]
{
assert_eq!(
Box::new("http://").validate_url(),
Err(UrlError::EmptyHost {
code: UrlErrorCode,
#[cfg(feature = "message")]
message: "empty host".to_owned(),
})
);
}
assert_eq!(
Box::new("http://").validate_url(),
Err(UrlError::EmptyHost {
code: UrlErrorCode,
#[cfg(feature = "message")]
message: "empty host".to_owned(),
})
);
assert_eq!(
Arc::new("http://").validate_url(),
Err(UrlError::from(ParseError::EmptyHost))
Expand Down
Loading