From bdf31c8a5d58962112ff34c92ded02d9d9fdc045 Mon Sep 17 00:00:00 2001 From: Steve Lotchouang Date: Tue, 29 Apr 2025 16:15:11 +0200 Subject: [PATCH] chore: update validator crate to 0.20.0 and add .idea to .gitignore --- .gitignore | 1 + Cargo.toml | 2 +- src/lib.rs | 5 +++-- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/.gitignore b/.gitignore index 5eeb887..c8003ef 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,5 @@ /target +/.idea # Added by cargo diff --git a/Cargo.toml b/Cargo.toml index 724bad8..e239a11 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -19,7 +19,7 @@ path = "src/lib.rs" rocket = { version = "0.5.0", default-features = false, features = [ "json", ] } -validator = { version = "0.18.0", features = ["derive"] } +validator = { version = "0.20.0", features = ["derive"] } [[example]] name = "json-validation" diff --git a/src/lib.rs b/src/lib.rs index af498ad..3e6203a 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -85,6 +85,7 @@ extern crate rocket; use rocket::{ data::{Data, FromData, Outcome as DataOutcome}, form, + form::name::NameBuf, form::{DataField, FromForm, ValueField}, http::Status, outcome::Outcome, @@ -277,8 +278,8 @@ impl<'r, T: Validate + FromForm<'r>> FromForm<'r> for Validated { .into_errors() .into_iter() .map(|e| form::Error { - name: Some(e.0.into()), - kind: form::error::ErrorKind::Validation(std::borrow::Cow::Borrowed(e.0)), + name: Some(NameBuf::from(e.0.clone().into_owned())), + kind: form::error::ErrorKind::Validation(e.0), value: None, entity: form::error::Entity::Value, })