1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
use crate::rules::validation::Validation;
use crate::utils::Error;
use macros::Rule;
use odra::types::Address;

/// Verifies if the worker attempts to bid on his own [`Job`](crate::bid_escrow::job::Job).
/// May return [Error::CannotBidOnOwnJob],
#[derive(Rule)]
pub struct CanBidOnOwnJob {
    worker: Address,
    job_poster: Address,
}

impl Validation for CanBidOnOwnJob {
    fn validate(&self) -> Result<(), Error> {
        if self.worker == self.job_poster {
            return Err(Error::CannotBidOnOwnJob);
        }
        Ok(())
    }
}