Keats/validator

Setting code to be string from ENUM

0xDjole opened this issue · 0 comments

pub struct CategoryCreatePayload {
    #[validate(length(min = 1, code = CategoryError::NotFound(String::from("HERE").to_string())))]
    pub name: String,
    #[validate(length(min = 1, code = "400.41"))]
    pub parent_id: Option<String>,
    pub tenant_id: String,
    #[validate(length(min = 1, code = "400.42"))]
    pub policies: Vec<PolicyCreatePayload>,
}

I'd like to use string from enums as a code and not a hardcoded string.
#[validate(length(min = 1, code = CategoryError::NotFound(String::from("HERE").to_string())))]

Like this