Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Setting code to be string from ENUM #273

Open
0xDjole opened this issue Sep 30, 2023 · 1 comment
Open

Setting code to be string from ENUM #273

0xDjole opened this issue Sep 30, 2023 · 1 comment

Comments

@0xDjole
Copy link

0xDjole commented Sep 30, 2023

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

@Keats
Copy link
Owner

Keats commented Nov 21, 2024

I don't think Rust allows that?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants