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

Code cannot be overridden for custom validator #284

Open
akkie opened this issue Jan 7, 2024 · 2 comments
Open

Code cannot be overridden for custom validator #284

akkie opened this issue Jan 7, 2024 · 2 comments

Comments

@akkie
Copy link

akkie commented Jan 7, 2024

The documentation indicates that the code can be overridden for a custom validator.

https://github.com/akkie/validator?tab=readme-ov-file#message-and-code

But this doesn't work. There is also no test for it.

@nMessage
Copy link

Specifying a custom Error code for Custom Validation checks fails.
eg

#[derive(Validate, Deserialize)]
pub struct ExampleStruct {
    #[validate(custom = "custom_check", code = "Custom error")]
    foo: String,
}

When using a custom validator like this, when a code is specified, Compiler errors with "validate not implemented for this struct"

The bellow example works just fine however.

#[derive(Validate, Deserialize)]
pub struct ExampleStruct {
    #[validate(custom = "custom_check")
    foo: String,
}

@Keats
Copy link
Owner

Keats commented Feb 12, 2024

Can you check with #249 ?

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

3 participants