chore: update validator crate

This commit is contained in:
khorshuheng 2024-12-11 12:33:46 +08:00
parent 7cd7ea1f9e
commit 719b95b94a
16 changed files with 605 additions and 222 deletions

671
Cargo.lock generated

File diff suppressed because it is too large Load Diff

View File

@ -58,7 +58,7 @@ reqwest = { workspace = true, features = [
unicode-segmentation = "1.10"
lazy_static.workspace = true
fancy-regex = "0.11.0"
validator = "0.16.1"
validator.workspace = true
bytes = "1.5.0"
rcgen = { version = "0.10.0", features = ["pem", "x509-parser"] }
mime = "0.3.17"
@ -283,6 +283,7 @@ sanitize-filename = "0.5.0"
base64 = "0.22"
md5 = "0.7.0"
pin-project = "1.1.5"
validator = "0.19"
zstd = { version = "0.13.2", features = [] }
# collaboration

View File

@ -19,7 +19,11 @@ askama = "0.12"
axum-extra = { version = "0.9", features = ["cookie"] }
serde.workspace = true
serde_json.workspace = true
redis = { version = "0.25.2", features = ["aio", "tokio-comp", "connection-manager"] }
redis = { version = "0.25.2", features = [
"aio",
"tokio-comp",
"connection-manager",
] }
uuid = { workspace = true, features = ["v4"] }
dotenvy = "0.15"
reqwest = "0.11.27"

View File

@ -17,7 +17,7 @@ sqlx = { workspace = true, default-features = false, features = [
"postgres",
"json",
], optional = true }
validator = { version = "0.16", optional = true }
validator = { workspace = true, optional = true }
url = { version = "2.5.0" }
actix-web = { version = "4.4.1", optional = true }
reqwest.workspace = true

View File

@ -6,7 +6,12 @@ edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
reqwest = { version = "0.12", features = ["json", "rustls-tls", "cookies", "stream"], optional = true }
reqwest = { version = "0.12", features = [
"json",
"rustls-tls",
"cookies",
"stream",
], optional = true }
serde = { version = "1.0.199", features = ["derive"], optional = true }
serde_json = { version = "1.0", optional = true }
thiserror = "1.0.58"
@ -20,11 +25,24 @@ pin-project = "1.1.5"
[dev-dependencies]
appflowy-ai-client = { path = ".", features = ["dto", "client-api"] }
tokio = { version = "1.37.0", features = ["macros", "test-util"] }
tracing-subscriber = { version = "0.3.18", features = ["registry", "env-filter", "ansi", "json"] }
tracing-subscriber = { version = "0.3.18", features = [
"registry",
"env-filter",
"ansi",
"json",
] }
uuid = { workspace = true, features = ["v4"] }
infra.workspace = true
[features]
default = ["client-api"]
client-api = ["dto", "reqwest", "serde", "serde_json", "tracing", "serde_repr", "infra/request_util"]
dto = ["serde", "serde_json", "serde_repr"]
client-api = [
"dto",
"reqwest",
"serde",
"serde_json",
"tracing",
"serde_repr",
"infra/request_util",
]
dto = ["serde", "serde_json", "serde_repr"]

View File

@ -8,12 +8,12 @@ edition = "2021"
native-tls = ["tokio-tungstenite/native-tls"]
native-tls-vendored = ["native-tls", "tokio-tungstenite/native-tls-vendored"]
rustls-tls-native-roots = [
"__rustls-tls",
"tokio-tungstenite/rustls-tls-native-roots",
"__rustls-tls",
"tokio-tungstenite/rustls-tls-native-roots",
]
rustls-tls-webpki-roots = [
"__rustls-tls",
"tokio-tungstenite/rustls-tls-webpki-roots",
"__rustls-tls",
"tokio-tungstenite/rustls-tls-webpki-roots",
]
__rustls-tls = []
@ -22,8 +22,8 @@ thiserror = "1"
http = "0.2"
httparse = "1.8"
futures-util = { version = "0.3", default-features = false, features = [
"sink",
"std",
"sink",
"std",
] }
[target.'cfg(not(target_arch = "wasm32"))'.dependencies]
@ -39,11 +39,11 @@ percent-encoding = "2.3.1"
[target.'cfg(target_arch = "wasm32")'.dependencies.web-sys]
version = "0.3"
features = [
"WebSocket",
"MessageEvent",
"CloseEvent",
"Event",
"ErrorEvent",
"BinaryType",
"Blob",
"WebSocket",
"MessageEvent",
"CloseEvent",
"Event",
"ErrorEvent",
"BinaryType",
"Blob",
]

View File

@ -11,7 +11,7 @@ crate-type = ["cdylib", "rlib"]
serde.workspace = true
serde_json.workspace = true
collab-entity = { workspace = true }
validator = { version = "0.16", features = ["validator_derive", "derive"] }
validator = { workspace = true, features = ["validator_derive", "derive"] }
chrono = { version = "0.4", features = ["serde"] }
uuid = { workspace = true, features = ["serde", "v4"] }
thiserror = "1.0.56"

View File

@ -24,13 +24,13 @@ pub const ZSTD_COMPRESSION_LEVEL: i32 = 3;
#[derive(Debug, Clone, Validate, Serialize, Deserialize)]
pub struct CreateCollabParams {
#[validate(custom = "validate_not_empty_str")]
#[validate(custom(function = "validate_not_empty_str"))]
pub workspace_id: String,
#[validate(custom = "validate_not_empty_str")]
#[validate(custom(function = "validate_not_empty_str"))]
pub object_id: String,
#[validate(custom = "validate_not_empty_payload")]
#[validate(custom(function = "validate_not_empty_payload"))]
pub encoded_collab_v1: Vec<u8>,
pub collab_type: CollabType,
@ -88,9 +88,9 @@ impl PendingCollabWrite {
#[derive(Debug, Clone, Validate, Serialize, Deserialize, PartialEq)]
pub struct CollabParams {
#[validate(custom = "validate_not_empty_str")]
#[validate(custom(function = "validate_not_empty_str"))]
pub object_id: String,
#[validate(custom = "validate_not_empty_payload")]
#[validate(custom(function = "validate_not_empty_payload"))]
pub encoded_collab_v1: Bytes,
pub collab_type: CollabType,
#[serde(default)]
@ -196,7 +196,7 @@ struct CollabParamsV0 {
#[derive(Debug, Clone, Validate, Serialize, Deserialize)]
pub struct BatchCreateCollabParams {
#[validate(custom = "validate_not_empty_str")]
#[validate(custom(function = "validate_not_empty_str"))]
pub workspace_id: String,
pub params_list: Vec<CollabParams>,
}
@ -219,19 +219,19 @@ pub struct UpdateCollabWebParams {
#[derive(Debug, Clone, Validate, Serialize, Deserialize)]
pub struct DeleteCollabParams {
#[validate(custom = "validate_not_empty_str")]
#[validate(custom(function = "validate_not_empty_str"))]
pub object_id: String,
#[validate(custom = "validate_not_empty_str")]
#[validate(custom(function = "validate_not_empty_str"))]
pub workspace_id: String,
}
#[derive(Debug, Clone, Validate)]
pub struct InsertSnapshotParams {
#[validate(custom = "validate_not_empty_str")]
#[validate(custom(function = "validate_not_empty_str"))]
pub object_id: String,
#[validate(custom = "validate_not_empty_payload")]
#[validate(custom(function = "validate_not_empty_payload"))]
pub data: Bytes,
#[validate(custom = "validate_not_empty_str")]
#[validate(custom(function = "validate_not_empty_str"))]
pub workspace_id: String,
pub collab_type: CollabType,
}
@ -250,9 +250,9 @@ pub struct QuerySnapshotParams {
#[derive(Debug, Clone, Validate, Serialize, Deserialize)]
pub struct QueryCollabParams {
#[validate(custom = "validate_not_empty_str")]
#[validate(custom(function = "validate_not_empty_str"))]
pub workspace_id: String,
#[validate]
#[validate(nested)]
pub inner: QueryCollab,
}
@ -295,7 +295,7 @@ impl Deref for QueryCollabParams {
#[derive(Debug, Clone, Validate, Serialize, Deserialize)]
pub struct QueryCollab {
#[validate(custom = "validate_not_empty_str")]
#[validate(custom(function = "validate_not_empty_str"))]
pub object_id: String,
pub collab_type: CollabType,
}
@ -369,9 +369,9 @@ pub struct WorkspaceUsage {
#[derive(Debug, Clone, Validate, Serialize, Deserialize)]
pub struct InsertCollabMemberParams {
pub uid: i64,
#[validate(custom = "validate_not_empty_str")]
#[validate(custom(function = "validate_not_empty_str"))]
pub workspace_id: String,
#[validate(custom = "validate_not_empty_str")]
#[validate(custom(function = "validate_not_empty_str"))]
pub object_id: String,
pub access_level: AFAccessLevel,
}
@ -381,9 +381,9 @@ pub type UpdateCollabMemberParams = InsertCollabMemberParams;
#[derive(Debug, Clone, Validate, Serialize, Deserialize)]
pub struct CollabMemberIdentify {
pub uid: i64,
#[validate(custom = "validate_not_empty_str")]
#[validate(custom(function = "validate_not_empty_str"))]
pub workspace_id: String,
#[validate(custom = "validate_not_empty_str")]
#[validate(custom(function = "validate_not_empty_str"))]
pub object_id: String,
}
@ -406,15 +406,15 @@ pub struct DefaultPublishViewInfoMeta {
#[derive(Debug, Clone, Validate, Serialize, Deserialize)]
pub struct QueryCollabMembers {
#[validate(custom = "validate_not_empty_str")]
#[validate(custom(function = "validate_not_empty_str"))]
pub workspace_id: String,
#[validate(custom = "validate_not_empty_str")]
#[validate(custom(function = "validate_not_empty_str"))]
pub object_id: String,
}
#[derive(Debug, Clone, Validate, Serialize, Deserialize)]
pub struct QueryWorkspaceMember {
#[validate(custom = "validate_not_empty_str")]
#[validate(custom(function = "validate_not_empty_str"))]
pub workspace_id: String,
pub uid: i64,
@ -1207,7 +1207,7 @@ pub struct ApproveAccessRequestParams {
#[derive(Debug, Clone, Validate, Serialize, Deserialize)]
pub struct CreateImportTask {
#[validate(custom = "validate_not_empty_str")]
#[validate(custom(function = "validate_not_empty_str"))]
pub workspace_name: String,
pub content_length: u64,
}

View File

@ -9,7 +9,7 @@ edition = "2021"
collab = { workspace = true }
collab-entity = { workspace = true }
collab-rt-entity = { workspace = true }
validator = { version = "0.16", features = ["validator_derive", "derive"] }
validator = { workspace = true, features = ["validator_derive", "derive"] }
database-entity.workspace = true
shared-entity.workspace = true
app-error = { workspace = true, features = ["sqlx_error", "validation_error"] }

View File

@ -15,10 +15,7 @@ bytes = { workspace = true }
tokio = { workspace = true, optional = true }
pin-project.workspace = true
futures = "0.3.30"
validator = { version = "0.16", features = [
"validator_derive",
"derive",
] }
validator = { workspace = true, features = ["validator_derive", "derive"] }
[features]
file_util = ["tokio/fs"]

View File

@ -29,10 +29,7 @@ pin-project = "1.1.5"
actix-web = { version = "4.4.1", default-features = false, features = [
"http2",
], optional = true }
validator = { version = "0.16", features = [
"validator_derive",
"derive",
] }
validator = { workspace = true, features = ["validator_derive", "derive"] }
futures = "0.3.30"
bytes = "1.6.0"
log = "0.4.21"

View File

@ -10,7 +10,7 @@ use validator::Validate;
#[derive(Debug, Clone, Validate, Serialize, Deserialize)]
pub struct CreateChatParams {
#[validate(custom = "validate_not_empty_str")]
#[validate(custom(function = "validate_not_empty_str"))]
pub chat_id: String,
pub name: String,
pub rag_ids: Vec<String>,
@ -18,7 +18,7 @@ pub struct CreateChatParams {
#[derive(Debug, Clone, Validate, Serialize, Deserialize)]
pub struct UpdateChatParams {
#[validate(custom = "validate_not_empty_str")]
#[validate(custom(function = "validate_not_empty_str"))]
pub name: Option<String>,
/// Key-value pairs of metadata to be updated.
@ -29,7 +29,7 @@ pub struct UpdateChatParams {
#[derive(Debug, Clone, Validate, Serialize, Deserialize)]
pub struct CreateChatMessageParams {
#[validate(custom = "validate_not_empty_str")]
#[validate(custom(function = "validate_not_empty_str"))]
pub content: String,
pub message_type: ChatMessageType,
#[serde(deserialize_with = "deserialize_metadata")]
@ -40,7 +40,7 @@ pub struct CreateChatMessageParams {
#[derive(Debug, Clone, Validate, Serialize, Deserialize)]
pub struct CreateChatMessageParamsV2 {
#[validate(custom = "validate_not_empty_str")]
#[validate(custom(function = "validate_not_empty_str"))]
pub content: String,
pub message_type: ChatMessageType,
#[serde(deserialize_with = "deserialize_metadata")]
@ -361,7 +361,7 @@ pub struct UpdateChatMessageResponse {
#[derive(Debug, Clone, Validate, Serialize, Deserialize)]
pub struct CreateAnswerMessageParams {
#[validate(custom = "validate_not_empty_str")]
#[validate(custom(function = "validate_not_empty_str"))]
pub content: String,
#[serde(skip_serializing_if = "Option::is_none")]

View File

@ -3,7 +3,7 @@
# Generate the current dependency list
cargo tree > current_deps.txt
BASELINE_COUNT=642
BASELINE_COUNT=720
CURRENT_COUNT=$(cat current_deps.txt | wc -l)
echo "Expected dependency count (baseline): $BASELINE_COUNT"

View File

@ -85,7 +85,7 @@ shared-entity = { workspace = true, features = ["cloud"] }
parking_lot = "0.12.1"
lazy_static = "1.4.0"
itertools = "0.12.0"
validator = "0.16.1"
validator.workspace = true
rayon.workspace = true
tiktoken-rs = "0.6.0"
unicode-segmentation = "1.9.0"

View File

@ -25,7 +25,12 @@ database.workspace = true
database-entity.workspace = true
tokio = { workspace = true, features = ["rt-multi-thread", "macros", "net"] }
tokio-stream = { version = "0.1", features = ["net"] }
redis = { workspace = true, features = ["aio", "tokio-comp", "connection-manager", "streams"] }
redis = { workspace = true, features = [
"aio",
"tokio-comp",
"connection-manager",
"streams",
] }
dotenvy = "0.15.0"
axum = "0.7.4"
thiserror = "1.0.58"
@ -33,7 +38,14 @@ tracing-subscriber = { version = "0.3", features = ["env-filter", "json"] }
serde_repr = "0.1.18"
futures = "0.3.30"
infra = { workspace = true, features = ["request_util"] }
sqlx = { workspace = true, default-features = false, features = ["runtime-tokio-rustls", "macros", "postgres", "uuid", "chrono", "migrate"] }
sqlx = { workspace = true, default-features = false, features = [
"runtime-tokio-rustls",
"macros",
"postgres",
"uuid",
"chrono",
"migrate",
] }
secrecy = { version = "0.8", features = ["serde"] }
aws-sdk-s3 = { version = "1.36.0", features = [
"behavior-version-latest",
@ -51,4 +63,3 @@ base64.workspace = true
prometheus-client = "0.22.3"
reqwest = "0.12.5"
zstd.workspace = true

View File

@ -1,4 +1,4 @@
use validator::validate_email;
use validator::ValidateEmail;
#[derive(Debug)]
pub struct UserEmail(pub String);
@ -9,7 +9,7 @@ impl UserEmail {
return Err("Email can not be empty or whitespace".to_string());
}
if validate_email(&s) {
if s.validate_email() {
Ok(Self(s))
} else {
Err("Invalid email".to_string())