Skip to content

Commit 72aa660

Browse files
authored
fix(ballot): correct validation logic for probability values (#529)
* fix(ballot): correct validation logic for probability values * fix(ballot): improve probability validation logic to use range check
1 parent e2f3ac6 commit 72aa660

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

ballot/src/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ impl Ballot {
2929
pub fn validate(&self) -> Result<(), String> {
3030
// Validate each probability
3131
for (&proof_type, &prob) in self.probabilities.iter() {
32-
if 0.0 > prob && 1.0 < prob {
32+
if !(0.0..=1.0).contains(&prob) {
3333
return Err(format!(
3434
"Invalid probability value {} for proof type {:?}, must be between 0 and 1",
3535
prob, proof_type

0 commit comments

Comments
 (0)