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

error: Unexpected literal type path #333

Open
simanacci opened this issue Jun 27, 2024 · 2 comments
Open

error: Unexpected literal type path #333

simanacci opened this issue Jun 27, 2024 · 2 comments

Comments

@simanacci
Copy link

I'm getting this error after upgrading to 18.1.
validator = { version = "0.18.1", features = [ "derive" ] }, lazy_static = 1.4.0, regex = 1.10.5

lazy_static! {
    pub static ref NO_WHITE_SPACE: Regex = Regex::new(r"^[^\s]+(\s+[^\s]+)*$").unwrap();
}
#[derive(Debug, Deserialize, Validate, Serialize)]
pub struct Login {
    #[validate(
        required,
        length(min = 1, message = "Enter your Username"),
        regex(path = *NO_WHITE_SPACE, message = "Spaces aren't allowed")
    )]
    pub username: Option<String>,
}
error: Unexpected literal type `path`
   --> /home/simanacci/.cargo/registry/src/index.crates.io-6f17d22bba15001f/validator_derive-0.18.1/src/lib.rs:228:22
    |
228 | #[darling(and_then = ValidationData::validate)]
    |                      ^^^^^^^^^^^^^^

   Compiling dummy v0.7.0
error[E0599]: no function or associated item named `from_derive_input` found for struct `ValidationData` in the current scope
   --> /home/simanacci/.cargo/registry/src/index.crates.io-6f17d22bba15001f/validator_derive-0.18.1/src/lib.rs:288:49
    |
229 | struct ValidationData {
    | --------------------- function or associated item `from_derive_input` not found for this struct
...
288 |     let validation_data = match ValidationData::from_derive_input(&input) {
    |                                                 ^^^^^^^^^^^^^^^^^ function or associated item not found in `ValidationData`
    |
    = help: items from traits can only be used if the trait is implemented and in scope
    = note: the following trait defines an item `from_derive_input`, perhaps you need to implement it:
            candidate #1: `FromDeriveInput`

For more information about this error, try `rustc --explain E0599`.
error: could not compile `validator_derive` (lib) due to 2 previous errors
warning: build failed, waiting for other jobs to finish...
@JustPretender
Copy link

I'm experiencing the same issue. @simanacci Have you managed to fix it?

@Keats
Copy link
Owner

Keats commented Aug 21, 2024

It's a bit odd, the sample from the issue works for me on master 🤔

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