chore: bump validator crate version (#6494)

This commit is contained in:
Richard Shiue
2024-10-08 21:38:58 +08:00
committed by GitHub
parent 8c956afabd
commit 6e0619c21e
24 changed files with 200 additions and 106 deletions

View File

@ -1334,7 +1334,7 @@ dependencies = [
"cssparser-macros",
"dtoa-short",
"itoa",
"phf 0.8.0",
"phf 0.11.2",
"smallvec",
]
@ -1378,6 +1378,41 @@ dependencies = [
"cipher",
]
[[package]]
name = "darling"
version = "0.20.8"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "54e36fcd13ed84ffdfda6f5be89b31287cbb80c439841fe69e04841435464391"
dependencies = [
"darling_core",
"darling_macro",
]
[[package]]
name = "darling_core"
version = "0.20.8"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9c2cf1c23a687a1feeb728783b993c4e1ad83d99f351801977dd809b48d0a70f"
dependencies = [
"fnv",
"ident_case",
"proc-macro2",
"quote",
"strsim 0.10.0",
"syn 2.0.47",
]
[[package]]
name = "darling_macro"
version = "0.20.8"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a668eda54683121533a393014d8692171709ff57a7d61f187b6e782719f8933f"
dependencies = [
"darling_core",
"quote",
"syn 2.0.47",
]
[[package]]
name = "dart-ffi"
version = "0.1.0"
@ -1464,7 +1499,7 @@ dependencies = [
"thiserror",
"tracing",
"uuid",
"validator",
"validator 0.16.1",
]
[[package]]
@ -1939,7 +1974,7 @@ dependencies = [
"tracing",
"tracing-subscriber",
"uuid",
"validator",
"validator 0.18.1",
"zip",
"zip-extensions",
]
@ -2116,7 +2151,7 @@ dependencies = [
"tokio-util",
"tracing",
"url",
"validator",
"validator 0.18.1",
]
[[package]]
@ -2186,7 +2221,7 @@ dependencies = [
"tracing",
"tracing-subscriber",
"uuid",
"validator",
"validator 0.18.1",
]
[[package]]
@ -2240,7 +2275,7 @@ dependencies = [
"thiserror",
"tokio",
"url",
"validator",
"validator 0.18.1",
]
[[package]]
@ -2279,7 +2314,7 @@ dependencies = [
"tracing",
"unicode-segmentation",
"uuid",
"validator",
"validator 0.18.1",
]
[[package]]
@ -2339,13 +2374,13 @@ dependencies = [
"protobuf",
"serde",
"serde_json",
"strsim",
"strsim 0.11.0",
"strum_macros 0.26.1",
"tantivy",
"tempfile",
"tokio",
"tracing",
"validator",
"validator 0.18.1",
]
[[package]]
@ -2550,7 +2585,7 @@ dependencies = [
"tracing",
"unicode-segmentation",
"uuid",
"validator",
"validator 0.18.1",
]
[[package]]
@ -3152,6 +3187,12 @@ dependencies = [
"cc",
]
[[package]]
name = "ident_case"
version = "1.0.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b9e0384b61958566e926dc50660321d12159025e767c18e043daf26b70104c39"
[[package]]
name = "idna"
version = "0.3.0"
@ -3420,7 +3461,7 @@ dependencies = [
"thread-id",
"tokio",
"tracing",
"validator",
"validator 0.18.1",
"wasm-bindgen",
"wasm-bindgen-futures",
]
@ -3446,7 +3487,7 @@ dependencies = [
"tempfile",
"tokio",
"tracing",
"validator",
"validator 0.18.1",
"walkdir",
"zip",
]
@ -4218,7 +4259,7 @@ version = "0.8.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3dfb61232e34fcb633f43d12c58f83c1df82962dcdfa565a4e866ffc17dafe12"
dependencies = [
"phf_macros",
"phf_macros 0.8.0",
"phf_shared 0.8.0",
"proc-macro-hack",
]
@ -4238,6 +4279,7 @@ version = "0.11.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ade2d8b8f33c7333b51bcf0428d37e217e9f32192ae4772156f65063b8ce03dc"
dependencies = [
"phf_macros 0.11.2",
"phf_shared 0.11.2",
]
@ -4305,6 +4347,19 @@ dependencies = [
"syn 1.0.109",
]
[[package]]
name = "phf_macros"
version = "0.11.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3444646e286606587e49f3bcf1679b8cef1dc2c5ecc29ddacaffc305180d464b"
dependencies = [
"phf_generator 0.11.2",
"phf_shared 0.11.2",
"proc-macro2",
"quote",
"syn 2.0.47",
]
[[package]]
name = "phf_shared"
version = "0.8.0"
@ -5701,6 +5756,12 @@ dependencies = [
"unicode-normalization",
]
[[package]]
name = "strsim"
version = "0.10.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "73473c0e59e6d5812c5dfe2a064a6444949f089e20eec9a2e5506596494e4623"
[[package]]
name = "strsim"
version = "0.11.0"
@ -6756,7 +6817,23 @@ dependencies = [
"serde_derive",
"serde_json",
"url",
"validator_derive",
"validator_derive 0.16.0",
]
[[package]]
name = "validator"
version = "0.18.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "db79c75af171630a3148bd3e6d7c4f42b6a9a014c2945bc5ed0020cbb8d9478e"
dependencies = [
"idna 0.5.0",
"once_cell",
"regex",
"serde",
"serde_derive",
"serde_json",
"url",
"validator_derive 0.18.2",
]
[[package]]
@ -6775,6 +6852,20 @@ dependencies = [
"validator_types",
]
[[package]]
name = "validator_derive"
version = "0.18.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "df0bcf92720c40105ac4b2dda2a4ea3aa717d4d6a862cc217da653a4bd5c6b10"
dependencies = [
"darling",
"once_cell",
"proc-macro-error",
"proc-macro2",
"quote",
"syn 2.0.47",
]
[[package]]
name = "validator_types"
version = "0.16.0"

View File

@ -96,7 +96,7 @@ collab-plugins = { version = "0.2" }
collab-user = { version = "0.2" }
collab-importer = { version = "0.1" }
yrs = "0.21.0"
validator = { version = "0.16.1", features = ["derive"] }
validator = { version = "0.18", features = ["derive"] }
tokio-util = "0.7.11"
zip = "2.2.0"
dashmap = "6.0.1"

View File

@ -9,10 +9,11 @@ use flowy_ai_pub::cloud::{
use flowy_derive::{ProtoBuf, ProtoBuf_Enum};
use lib_infra::validator_fn::required_not_empty_str;
use validator::Validate;
#[derive(Default, ProtoBuf, Validate, Clone, Debug)]
pub struct ChatId {
#[pb(index = 1)]
#[validate(custom = "required_not_empty_str")]
#[validate(custom(function = "required_not_empty_str"))]
pub value: String,
}
@ -36,11 +37,11 @@ pub struct FilePB {
#[derive(Default, ProtoBuf, Validate, Clone, Debug)]
pub struct SendChatPayloadPB {
#[pb(index = 1)]
#[validate(custom = "required_not_empty_str")]
#[validate(custom(function = "required_not_empty_str"))]
pub chat_id: String,
#[pb(index = 2)]
#[validate(custom = "required_not_empty_str")]
#[validate(custom(function = "required_not_empty_str"))]
pub message: String,
#[pb(index = 3)]
@ -50,11 +51,11 @@ pub struct SendChatPayloadPB {
#[derive(Default, ProtoBuf, Validate, Clone, Debug)]
pub struct StreamChatPayloadPB {
#[pb(index = 1)]
#[validate(custom = "required_not_empty_str")]
#[validate(custom(function = "required_not_empty_str"))]
pub chat_id: String,
#[pb(index = 2)]
#[validate(custom = "required_not_empty_str")]
#[validate(custom(function = "required_not_empty_str"))]
pub message: String,
#[pb(index = 3)]
@ -100,7 +101,7 @@ pub enum ChatMessageMetaTypePB {
#[derive(Default, ProtoBuf, Validate, Clone, Debug)]
pub struct StopStreamPB {
#[pb(index = 1)]
#[validate(custom = "required_not_empty_str")]
#[validate(custom(function = "required_not_empty_str"))]
pub chat_id: String,
}
@ -114,7 +115,7 @@ pub enum ChatMessageTypePB {
#[derive(Default, ProtoBuf, Validate, Clone, Debug)]
pub struct LoadPrevChatMessagePB {
#[pb(index = 1)]
#[validate(custom = "required_not_empty_str")]
#[validate(custom(function = "required_not_empty_str"))]
pub chat_id: String,
#[pb(index = 2)]
@ -127,7 +128,7 @@ pub struct LoadPrevChatMessagePB {
#[derive(Default, ProtoBuf, Validate, Clone, Debug)]
pub struct LoadNextChatMessagePB {
#[pb(index = 1)]
#[validate(custom = "required_not_empty_str")]
#[validate(custom(function = "required_not_empty_str"))]
pub chat_id: String,
#[pb(index = 2)]
@ -367,11 +368,11 @@ pub enum ModelTypePB {
#[derive(Default, ProtoBuf, Validate, Clone, Debug)]
pub struct ChatFilePB {
#[pb(index = 1)]
#[validate(custom = "required_not_empty_str")]
#[validate(custom(function = "required_not_empty_str"))]
pub file_path: String,
#[pb(index = 2)]
#[validate(custom = "required_not_empty_str")]
#[validate(custom(function = "required_not_empty_str"))]
pub chat_id: String,
}
@ -510,17 +511,17 @@ pub struct OfflineAIPB {
#[derive(Default, ProtoBuf, Validate, Clone, Debug)]
pub struct CreateChatContextPB {
#[pb(index = 1)]
#[validate(custom = "required_not_empty_str")]
#[validate(custom(function = "required_not_empty_str"))]
pub content_type: String,
#[pb(index = 2)]
#[validate(custom = "required_not_empty_str")]
#[validate(custom(function = "required_not_empty_str"))]
pub text: String,
#[pb(index = 3)]
pub metadata: HashMap<String, String>,
#[pb(index = 4)]
#[validate(custom = "required_not_empty_str")]
#[validate(custom(function = "required_not_empty_str"))]
pub chat_id: String,
}

View File

@ -8,14 +8,14 @@ use validator::Validate;
#[derive(Default, ProtoBuf, Validate)]
pub struct UpdateCalculationChangesetPB {
#[pb(index = 1)]
#[validate(custom = "required_not_empty_str")]
#[validate(custom(function = "required_not_empty_str"))]
pub view_id: String,
#[pb(index = 2, one_of)]
pub calculation_id: Option<String>,
#[pb(index = 3)]
#[validate(custom = "required_not_empty_str")]
#[validate(custom(function = "required_not_empty_str"))]
pub field_id: String,
#[pb(index = 4)]
@ -25,15 +25,15 @@ pub struct UpdateCalculationChangesetPB {
#[derive(Default, ProtoBuf, Validate)]
pub struct RemoveCalculationChangesetPB {
#[pb(index = 1)]
#[validate(custom = "required_not_empty_str")]
#[validate(custom(function = "required_not_empty_str"))]
pub view_id: String,
#[pb(index = 2)]
#[validate(custom = "required_not_empty_str")]
#[validate(custom(function = "required_not_empty_str"))]
pub field_id: String,
#[pb(index = 3)]
#[validate(custom = "required_not_empty_str")]
#[validate(custom(function = "required_not_empty_str"))]
pub calculation_id: String,
}

View File

@ -77,7 +77,7 @@ pub struct RepeatedDatabaseIdPB {
#[derive(Clone, ProtoBuf, Default, Debug, Validate)]
pub struct DatabaseViewIdPB {
#[pb(index = 1)]
#[validate(custom = "required_not_empty_str")]
#[validate(custom(function = "required_not_empty_str"))]
pub value: String,
}

View File

@ -380,11 +380,11 @@ impl TryInto<GetFieldParams> for GetFieldPayloadPB {
#[derive(Debug, Clone, Default, ProtoBuf, Validate)]
pub struct FieldChangesetPB {
#[pb(index = 1)]
#[validate(custom = "required_not_empty_str")]
#[validate(custom(function = "required_not_empty_str"))]
pub field_id: String,
#[pb(index = 2)]
#[validate(custom = "required_not_empty_str")]
#[validate(custom(function = "required_not_empty_str"))]
pub view_id: String,
#[pb(index = 3, one_of)]
@ -606,11 +606,11 @@ impl TryInto<FieldIdParams> for DuplicateFieldPayloadPB {
#[derive(Debug, Clone, Default, ProtoBuf, Validate)]
pub struct ClearFieldPayloadPB {
#[pb(index = 1)]
#[validate(custom = "lib_infra::validator_fn::required_not_empty_str")]
#[validate(custom(function = "required_not_empty_str"))]
pub field_id: String,
#[pb(index = 2)]
#[validate(custom = "lib_infra::validator_fn::required_not_empty_str")]
#[validate(custom(function = "required_not_empty_str"))]
pub view_id: String,
}

View File

@ -101,11 +101,11 @@ impl std::convert::From<Vec<FieldSettingsPB>> for RepeatedFieldSettingsPB {
#[derive(Debug, Default, Clone, ProtoBuf, Validate)]
pub struct FieldSettingsChangesetPB {
#[validate(custom = "required_not_empty_str")]
#[validate(custom(function = "required_not_empty_str"))]
#[pb(index = 1)]
pub view_id: String,
#[validate(custom = "required_not_empty_str")]
#[validate(custom(function = "required_not_empty_str"))]
#[pb(index = 2)]
pub field_id: String,

View File

@ -213,7 +213,7 @@ impl From<Vec<FilterPB>> for RepeatedFilterPB {
pub struct InsertFilterPB {
/// If None, the filter will be the root of a new filter tree
#[pb(index = 1, one_of)]
#[validate(custom = "crate::entities::utils::validate_filter_id")]
#[validate(custom(function = "crate::entities::utils::validate_filter_id"))]
pub parent_filter_id: Option<String>,
#[pb(index = 2)]
@ -223,7 +223,7 @@ pub struct InsertFilterPB {
#[derive(ProtoBuf, Debug, Default, Clone, Validate)]
pub struct UpdateFilterTypePB {
#[pb(index = 1)]
#[validate(custom = "crate::entities::utils::validate_filter_id")]
#[validate(custom(function = "crate::entities::utils::validate_filter_id"))]
pub filter_id: String,
#[pb(index = 2)]
@ -233,7 +233,7 @@ pub struct UpdateFilterTypePB {
#[derive(ProtoBuf, Debug, Default, Clone, Validate)]
pub struct UpdateFilterDataPB {
#[pb(index = 1)]
#[validate(custom = "crate::entities::utils::validate_filter_id")]
#[validate(custom(function = "crate::entities::utils::validate_filter_id"))]
pub filter_id: String,
#[pb(index = 2)]
@ -243,7 +243,7 @@ pub struct UpdateFilterDataPB {
#[derive(ProtoBuf, Debug, Default, Clone, Validate)]
pub struct DeleteFilterPB {
#[pb(index = 1)]
#[validate(custom = "crate::entities::utils::validate_filter_id")]
#[validate(custom(function = "crate::entities::utils::validate_filter_id"))]
pub filter_id: String,
}

View File

@ -2,6 +2,7 @@ use std::convert::TryInto;
use flowy_derive::ProtoBuf;
use flowy_error::ErrorCode;
use lib_infra::validator_fn::required_not_empty_str;
use validator::Validate;
use crate::entities::parser::NotEmptyStr;
@ -145,11 +146,11 @@ pub struct GroupByFieldParams {
#[derive(Eq, PartialEq, ProtoBuf, Debug, Default, Clone, Validate)]
pub struct UpdateGroupPB {
#[pb(index = 1)]
#[validate(custom = "lib_infra::validator_fn::required_not_empty_str")]
#[validate(custom(function = "required_not_empty_str"))]
pub view_id: String,
#[pb(index = 2)]
#[validate(custom = "lib_infra::validator_fn::required_not_empty_str")]
#[validate(custom(function = "required_not_empty_str"))]
pub group_id: String,
#[pb(index = 3, one_of)]

View File

@ -460,14 +460,14 @@ pub struct RepeatedRowIdPB {
#[derive(ProtoBuf, Default, Validate)]
pub struct CreateRowPayloadPB {
#[pb(index = 1)]
#[validate(custom = "required_not_empty_str")]
#[validate(custom(function = "required_not_empty_str"))]
pub view_id: String,
#[pb(index = 2)]
pub row_position: OrderObjectPositionPB,
#[pb(index = 3, one_of)]
#[validate(custom = "required_not_empty_str")]
#[validate(custom(function = "required_not_empty_str"))]
pub group_id: Option<String>,
#[pb(index = 4)]
@ -494,14 +494,14 @@ pub struct SummaryRowPB {
#[derive(Debug, Default, Clone, ProtoBuf, Validate)]
pub struct TranslateRowPB {
#[pb(index = 1)]
#[validate(custom = "required_not_empty_str")]
#[validate(custom(function = "required_not_empty_str"))]
pub view_id: String,
#[pb(index = 2)]
#[validate(custom = "required_not_empty_str")]
#[validate(custom(function = "required_not_empty_str"))]
pub row_id: String,
#[pb(index = 3)]
#[validate(custom = "required_not_empty_str")]
#[validate(custom(function = "required_not_empty_str"))]
pub field_id: String,
}

View File

@ -71,42 +71,42 @@ impl std::convert::From<DatabaseLayoutPB> for DatabaseLayout {
#[derive(Default, Validate, ProtoBuf)]
pub struct DatabaseSettingChangesetPB {
#[pb(index = 1)]
#[validate(custom = "lib_infra::validator_fn::required_not_empty_str")]
#[validate(custom(function = "lib_infra::validator_fn::required_not_empty_str"))]
pub view_id: String,
#[pb(index = 2, one_of)]
pub layout_type: Option<DatabaseLayoutPB>,
#[pb(index = 3, one_of)]
#[validate]
#[validate(nested)]
pub insert_filter: Option<InsertFilterPB>,
#[pb(index = 4, one_of)]
#[validate]
#[validate(nested)]
pub update_filter_type: Option<UpdateFilterTypePB>,
#[pb(index = 5, one_of)]
#[validate]
#[validate(nested)]
pub update_filter_data: Option<UpdateFilterDataPB>,
#[pb(index = 6, one_of)]
#[validate]
#[validate(nested)]
pub delete_filter: Option<DeleteFilterPB>,
#[pb(index = 7, one_of)]
#[validate]
#[validate(nested)]
pub update_group: Option<UpdateGroupPB>,
#[pb(index = 8, one_of)]
#[validate]
#[validate(nested)]
pub update_sort: Option<UpdateSortPayloadPB>,
#[pb(index = 9, one_of)]
#[validate]
#[validate(nested)]
pub reorder_sort: Option<ReorderSortPayloadPB>,
#[pb(index = 10, one_of)]
#[validate]
#[validate(nested)]
pub delete_sort: Option<DeleteSortPayloadPB>,
}

View File

@ -1,4 +1,5 @@
use flowy_derive::{ProtoBuf, ProtoBuf_Enum};
use lib_infra::validator_fn::required_not_empty_str;
use validator::Validate;
use crate::services::sort::{Sort, SortCondition};
@ -96,16 +97,16 @@ impl std::convert::From<SortConditionPB> for SortCondition {
#[derive(ProtoBuf, Debug, Default, Clone, Validate)]
pub struct UpdateSortPayloadPB {
#[pb(index = 1)]
#[validate(custom = "lib_infra::validator_fn::required_not_empty_str")]
#[validate(custom(function = "required_not_empty_str"))]
pub view_id: String,
#[pb(index = 2)]
#[validate(custom = "lib_infra::validator_fn::required_not_empty_str")]
#[validate(custom(function = "required_not_empty_str"))]
pub field_id: String,
/// Create a new sort if the sort_id is None
#[pb(index = 3, one_of)]
#[validate(custom = "super::utils::validate_sort_id")]
#[validate(custom(function = "super::utils::validate_sort_id"))]
pub sort_id: Option<String>,
#[pb(index = 4)]
@ -115,26 +116,26 @@ pub struct UpdateSortPayloadPB {
#[derive(Debug, Default, Clone, Validate, ProtoBuf)]
pub struct ReorderSortPayloadPB {
#[pb(index = 1)]
#[validate(custom = "lib_infra::validator_fn::required_not_empty_str")]
#[validate(custom(function = "required_not_empty_str"))]
pub view_id: String,
#[pb(index = 2)]
#[validate(custom = "super::utils::validate_sort_id")]
#[validate(custom(function = "super::utils::validate_sort_id"))]
pub from_sort_id: String,
#[pb(index = 3)]
#[validate(custom = "super::utils::validate_sort_id")]
#[validate(custom(function = "super::utils::validate_sort_id"))]
pub to_sort_id: String,
}
#[derive(ProtoBuf, Debug, Default, Clone, Validate)]
pub struct DeleteSortPayloadPB {
#[pb(index = 1)]
#[validate(custom = "lib_infra::validator_fn::required_not_empty_str")]
#[validate(custom(function = "required_not_empty_str"))]
pub view_id: String,
#[pb(index = 2)]
#[validate(custom = "super::utils::validate_sort_id")]
#[validate(custom(function = "super::utils::validate_sort_id"))]
pub sort_id: String,
}

View File

@ -20,7 +20,7 @@ flowy-notification = { workspace = true }
flowy-error = { path = "../flowy-error", features = ["impl_from_serde", "impl_from_dispatch_error", "impl_from_collab_document", "impl_from_collab_persistence"] }
lib-dispatch = { workspace = true }
lib-infra = { workspace = true }
validator = { version = "0.16.0", features = ["derive"] }
validator = { workspace = true, features = ["derive"] }
protobuf.workspace = true
bytes.workspace = true
nanoid = "0.4.0"

View File

@ -81,15 +81,15 @@ pub struct DocumentRedoUndoResponsePB {
#[derive(Default, ProtoBuf, Validate)]
pub struct UploadFileParamsPB {
#[pb(index = 1)]
#[validate(custom = "required_not_empty_str")]
#[validate(custom(function = "required_not_empty_str"))]
pub workspace_id: String,
#[pb(index = 2)]
#[validate(custom = "required_not_empty_str")]
#[validate(custom(function = "required_not_empty_str"))]
pub document_id: String,
#[pb(index = 3)]
#[validate(custom = "required_valid_path")]
#[validate(custom(function = "required_valid_path"))]
pub local_file_path: String,
}
@ -100,7 +100,7 @@ pub struct UploadedFilePB {
pub url: String,
#[pb(index = 2)]
#[validate(custom = "required_valid_path")]
#[validate(custom(function = "required_valid_path"))]
pub local_file_path: String,
}
@ -111,7 +111,7 @@ pub struct DownloadFilePB {
pub url: String,
#[pb(index = 2)]
#[validate(custom = "required_valid_path")]
#[validate(custom(function = "required_valid_path"))]
pub local_file_path: String,
}

View File

@ -508,7 +508,7 @@ pub enum InputType {
#[derive(Default, ProtoBuf, Debug, Validate)]
pub struct ConvertDataToJsonPayloadPB {
#[pb(index = 1)]
#[validate(custom = "required_not_empty_str")]
#[validate(custom(function = "required_not_empty_str"))]
pub data: String,
#[pb(index = 2)]

View File

@ -71,7 +71,7 @@ pub struct ImportValuePayloadPB {
#[derive(Clone, Debug, Validate, ProtoBuf, Default)]
pub struct ImportPayloadPB {
#[pb(index = 1)]
#[validate(custom = "required_not_empty_str")]
#[validate(custom(function = "required_not_empty_str"))]
pub parent_view_id: String,
#[pb(index = 2)]
@ -81,11 +81,11 @@ pub struct ImportPayloadPB {
#[derive(Clone, Debug, Validate, ProtoBuf, Default)]
pub struct ImportZipPB {
#[pb(index = 1)]
#[validate(custom = "required_not_empty_str")]
#[validate(custom(function = "required_not_empty_str"))]
pub parent_view_id: String,
#[pb(index = 2)]
#[validate(custom = "required_valid_path")]
#[validate(custom(function = "required_valid_path"))]
pub file_path: String,
}

View File

@ -38,7 +38,7 @@ strsim = "0.11.0"
strum_macros = "0.26.1"
tantivy = { version = "0.22.0" }
tempfile = "3.9.0"
validator = { version = "0.16.0", features = ["derive"] }
validator = { workspace = true, features = ["derive"] }
diesel.workspace = true
diesel_derives = { version = "2.1.0", features = ["sqlite", "r2d2"] }

View File

@ -1,10 +1,11 @@
use flowy_derive::ProtoBuf;
use lib_infra::validator_fn::required_not_empty_str;
use validator::Validate;
#[derive(ProtoBuf, Validate, Default)]
pub struct ImportAppFlowyDataPB {
#[pb(index = 1)]
#[validate(custom = "lib_infra::validator_fn::required_not_empty_str")]
#[validate(custom(function = "required_not_empty_str"))]
pub path: String,
#[pb(index = 2, one_of)]

View File

@ -1,5 +1,5 @@
use flowy_error::ErrorCode;
use validator::validate_email;
use validator::ValidateEmail;
#[derive(Debug)]
pub struct UserEmail(pub String);
@ -10,7 +10,7 @@ impl UserEmail {
return Err(ErrorCode::EmailIsEmpty);
}
if validate_email(&s) {
if ValidateEmail::validate_email(&s) {
Ok(Self(s))
} else {
Err(ErrorCode::EmailFormatInvalid)

View File

@ -1,9 +1,10 @@
use std::convert::TryInto;
use std::str::FromStr;
use validator::Validate;
use flowy_derive::{ProtoBuf, ProtoBuf_Enum};
use flowy_user_pub::entities::*;
use lib_infra::validator_fn::required_not_empty_str;
use validator::Validate;
use crate::entities::parser::{UserEmail, UserIcon, UserName, UserOpenaiKey, UserPassword};
use crate::entities::{AIModelPB, AuthenticatorPB};
@ -222,7 +223,7 @@ impl From<Vec<UserWorkspace>> for RepeatedUserWorkspacePB {
#[derive(ProtoBuf, Default, Debug, Clone, Validate)]
pub struct UserWorkspacePB {
#[pb(index = 1)]
#[validate(custom = "lib_infra::validator_fn::required_not_empty_str")]
#[validate(custom(function = "required_not_empty_str"))]
pub workspace_id: String,
#[pb(index = 2)]

View File

@ -46,7 +46,7 @@ pub struct RepeatedWorkspaceMemberPB {
#[derive(ProtoBuf, Default, Clone, Validate)]
pub struct WorkspaceMemberInvitationPB {
#[pb(index = 1)]
#[validate(custom = "required_not_empty_str")]
#[validate(custom(function = "required_not_empty_str"))]
pub workspace_id: String,
#[pb(index = 2)]
@ -98,7 +98,7 @@ impl From<WorkspaceInvitation> for WorkspaceInvitationPB {
#[derive(ProtoBuf, Default, Clone, Validate)]
pub struct AcceptWorkspaceInvitationPB {
#[pb(index = 1)]
#[validate(custom = "required_not_empty_str")]
#[validate(custom(function = "required_not_empty_str"))]
pub invite_id: String,
}
@ -106,7 +106,7 @@ pub struct AcceptWorkspaceInvitationPB {
#[derive(ProtoBuf, Default, Clone, Validate)]
pub struct AddWorkspaceMemberPB {
#[pb(index = 1)]
#[validate(custom = "required_not_empty_str")]
#[validate(custom(function = "required_not_empty_str"))]
pub workspace_id: String,
#[pb(index = 2)]
@ -117,14 +117,14 @@ pub struct AddWorkspaceMemberPB {
#[derive(ProtoBuf, Default, Clone, Validate)]
pub struct QueryWorkspacePB {
#[pb(index = 1)]
#[validate(custom = "required_not_empty_str")]
#[validate(custom(function = "required_not_empty_str"))]
pub workspace_id: String,
}
#[derive(ProtoBuf, Default, Clone, Validate)]
pub struct RemoveWorkspaceMemberPB {
#[pb(index = 1)]
#[validate(custom = "required_not_empty_str")]
#[validate(custom(function = "required_not_empty_str"))]
pub workspace_id: String,
#[pb(index = 2)]
@ -135,7 +135,7 @@ pub struct RemoveWorkspaceMemberPB {
#[derive(ProtoBuf, Default, Clone, Validate)]
pub struct UpdateWorkspaceMemberPB {
#[pb(index = 1)]
#[validate(custom = "required_not_empty_str")]
#[validate(custom(function = "required_not_empty_str"))]
pub workspace_id: String,
#[pb(index = 2)]
@ -178,14 +178,14 @@ impl From<Role> for AFRolePB {
#[derive(ProtoBuf, Default, Clone, Validate)]
pub struct UserWorkspaceIdPB {
#[pb(index = 1)]
#[validate(custom = "required_not_empty_str")]
#[validate(custom(function = "required_not_empty_str"))]
pub workspace_id: String,
}
#[derive(ProtoBuf, Default, Clone, Validate)]
pub struct CancelWorkspaceSubscriptionPB {
#[pb(index = 1)]
#[validate(custom = "required_not_empty_str")]
#[validate(custom(function = "required_not_empty_str"))]
pub workspace_id: String,
#[pb(index = 2)]
@ -198,7 +198,7 @@ pub struct CancelWorkspaceSubscriptionPB {
#[derive(ProtoBuf, Default, Clone, Validate)]
pub struct SuccessWorkspaceSubscriptionPB {
#[pb(index = 1)]
#[validate(custom = "required_not_empty_str")]
#[validate(custom(function = "required_not_empty_str"))]
pub workspace_id: String,
#[pb(index = 2, one_of)]
@ -214,25 +214,25 @@ pub struct WorkspaceMemberIdPB {
#[derive(ProtoBuf, Default, Clone, Validate)]
pub struct CreateWorkspacePB {
#[pb(index = 1)]
#[validate(custom = "required_not_empty_str")]
#[validate(custom(function = "required_not_empty_str"))]
pub name: String,
}
#[derive(ProtoBuf, Default, Clone, Validate)]
pub struct RenameWorkspacePB {
#[pb(index = 1)]
#[validate(custom = "required_not_empty_str")]
#[validate(custom(function = "required_not_empty_str"))]
pub workspace_id: String,
#[pb(index = 2)]
#[validate(custom = "required_not_empty_str")]
#[validate(custom(function = "required_not_empty_str"))]
pub new_name: String,
}
#[derive(ProtoBuf, Default, Clone, Validate)]
pub struct ChangeWorkspaceIconPB {
#[pb(index = 1)]
#[validate(custom = "required_not_empty_str")]
#[validate(custom(function = "required_not_empty_str"))]
pub workspace_id: String,
#[pb(index = 2)]
@ -242,7 +242,7 @@ pub struct ChangeWorkspaceIconPB {
#[derive(ProtoBuf, Default, Clone, Validate, Debug)]
pub struct SubscribeWorkspacePB {
#[pb(index = 1)]
#[validate(custom = "required_not_empty_str")]
#[validate(custom(function = "required_not_empty_str"))]
pub workspace_id: String,
#[pb(index = 2)]
@ -397,7 +397,7 @@ impl From<AFWorkspaceSettings> for UseAISettingPB {
#[derive(ProtoBuf, Default, Clone, Validate)]
pub struct UpdateUserWorkspaceSettingPB {
#[pb(index = 1)]
#[validate(custom = "required_not_empty_str")]
#[validate(custom(function = "required_not_empty_str"))]
pub workspace_id: String,
#[pb(index = 2, one_of)]
@ -643,7 +643,7 @@ impl From<i64> for WorkspaceSubscriptionStatusPB {
#[derive(ProtoBuf, Default, Clone, Validate)]
pub struct UpdateWorkspaceSubscriptionPaymentPeriodPB {
#[pb(index = 1)]
#[validate(custom = "required_not_empty_str")]
#[validate(custom(function = "required_not_empty_str"))]
pub workspace_id: String,
#[pb(index = 2)]

View File

@ -21,7 +21,7 @@ derivative = "2.2.0"
serde_json = { workspace = true, optional = true }
serde = { version = "1.0", features = ["derive"], optional = true }
serde_repr = { workspace = true, optional = true }
validator = "0.16.1"
validator = { workspace = true, features = ["derive"] }
tracing.workspace = true
bincode = { version = "1.3", optional = true }
protobuf = { workspace = true, optional = true }
@ -45,5 +45,3 @@ default = ["local_set", "use_protobuf"]
use_serde = ["bincode", "serde_json", "serde", "serde_repr"]
use_protobuf = ["protobuf"]
local_set = []

View File

@ -2,7 +2,7 @@ use std::fmt::{Debug, Formatter};
use std::ops;
use bytes::Bytes;
use validator::ValidationErrors;
use validator::{Validate, ValidationErrors};
use crate::{
byte_trait::*,
@ -28,7 +28,7 @@ impl<T> AFPluginData<T> {
impl<T> AFPluginData<T>
where
T: validator::Validate,
T: Validate,
{
pub fn try_into_inner(self) -> Result<T, ValidationErrors> {
self.0.validate()?;

View File

@ -18,7 +18,7 @@ md5 = "0.7.0"
anyhow.workspace = true
walkdir = "2.4.0"
tempfile = "3.8.1"
validator = { version = "0.16.1", features = ["derive"] }
validator = { workspace = true, features = ["derive"] }
tracing.workspace = true
atomic_refcell = "0.1"
allo-isolate = { version = "^0.1", features = ["catch-unwind"], optional = true }