Skip to content

Commit

Permalink
Rename validate_positive_odd -> validate_positively_odd
Browse files Browse the repository at this point in the history
  • Loading branch information
greyblake committed Aug 24, 2024
1 parent d49ba9d commit f31d01b
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 12 deletions.
4 changes: 2 additions & 2 deletions examples/custom_error/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use nutype::nutype;
use thiserror::Error;

#[nutype(
validate(with = validate_positive_odd, error = PositivelyOddError),
validate(with = validate_positively_odd, error = PositivelyOddError),
derive(Debug, FromStr),
)]
struct PositivelyOdd(i32);
Expand All @@ -16,7 +16,7 @@ enum PositivelyOddError {
Even,
}

fn validate_positive_odd(value: &i32) -> Result<(), PositivelyOddError> {
fn validate_positively_odd(value: &i32) -> Result<(), PositivelyOddError> {
if *value < 0 {
return Err(PositivelyOddError::Negative);
}
Expand Down
12 changes: 2 additions & 10 deletions test_suite/tests/integer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -838,7 +838,7 @@ mod custom_error {
use thiserror::Error;

#[nutype(
validate(with = validate_positive_odd, error = PositivelyOddError),
validate(with = validate_positively_odd, error = PositivelyOddError),
derive(Debug, FromStr),
)]
struct PositivelyOdd(i32);
Expand All @@ -852,7 +852,7 @@ mod custom_error {
Even,
}

fn validate_positive_odd(value: &i32) -> Result<(), PositivelyOddError> {
fn validate_positively_odd(value: &i32) -> Result<(), PositivelyOddError> {
if *value < 0 {
return Err(PositivelyOddError::Negative);
}
Expand All @@ -876,14 +876,6 @@ mod custom_error {
assert_eq!(err, PositivelyOddError::Even);
}

{
let err: PositivelyOddParseError = "-3".parse::<PositivelyOdd>().unwrap_err();
assert!(matches!(
err,
PositivelyOddParseError::Validate(PositivelyOddError::Negative)
));
}

let podd: PositivelyOdd = PositivelyOdd::try_new(3).unwrap();
assert_eq!(podd.into_inner(), 3);
}
Expand Down

0 comments on commit f31d01b

Please sign in to comment.