rambler-digital-solutions / actix-web-validator

Rust library for providing validation mechanism to actix-web with Validator crate.
MIT License
101 stars 26 forks source link

Compatibility with Validator v. 0.15.0 #32

Closed goshoo closed 2 years ago

goshoo commented 2 years ago

Hi,

I tried to compile the following example with Validator 0.15.0 and I got the following error.

[post("/user/info")]

| ^^^^^^^^^^^^^^^^^^^^^ the trait `validator::traits::Validate` is not implemented for `Info`

This is the example:

use actix_web::{post, web};
use actix_web_validator::Json;
use serde::{Deserialize, Serialize};
use validator::Validate;

#[derive(Deserialize, Serialize, Debug, Validate)]
pub struct Info {
    #[validate(length(min = 3, max = 6))]
    username: String,
    #[validate(email)]
    email: String,
    password: String,
    confirm_password: String,
}

#[post("/user/info")]
pub async fn info(info: Json<Info>) -> web::Json<Info> {
    web::Json(Info {
        username: info.username.clone(),
        email: info.email.clone(),
        password: info.password.clone(),
        confirm_password: info.confirm_password.clone(),
    })
}

The example works just fine with Validator 0.14.0