use anyhow::bail;

#[derive(Clone, Debug, Eq, PartialEq, Hash)]
pub struct Decimal {
    pub precision: i32,
    pub scale: i32,
}

impl Decimal {
    pub fn new(precision: i32, scale: i32) -> anyhow::Result<Self> {
        if scale < 0 || precision < 0 {
            bail!("Scale and precision must be non-negative");
        }

        if scale > precision {
            bail!("Scale must be less than or equal to precision");
        }

        Ok(Self { precision, scale })
    }
}
