Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
79 changes: 75 additions & 4 deletions packages/fortifier-macros/src/validate/type.rs
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,77 @@ const KEYED_CONTAINER_TYPES: [&str; 6] = [
"std::collections::HashMap",
];

/// Ecosystem types.
///
/// De facto standard types.
const ECOSYSTEM_TYPES: [&str; 65] = [
"Date",
"DateTime",
"Days",
"Decimal",
"Duration",
"FixedI8",
"FixedI16",
"FixedI32",
"FixedI64",
"FixedI128",
"FixedU8",
"FixedU16",
"FixedU32",
"FixedU64",
"FixedU128",
"Month",
"Months",
"NaiveDate",
"NaiveDateTime",
"NaiveTime",
"OffsetDateTime",
"OrderedFloat",
"PrimitiveDateTime",
"Regex",
"Time",
"TimeDelta",
"UtcDateTime",
"Uuid",
"Weekday",
"WeekdaySet",
"chrono::Date",
"chrono::DateTime",
"chrono::Days",
"chrono::Duration",
"chrono::Month",
"chrono::Months",
"chrono::NaiveDate",
"chrono::NaiveDateTime",
"chrono::NaiveTime",
"chrono::TimeDelta",
"chrono::Weekday",
"chrono::WeekdaySet",
"fancy_regex::Regex",
"fixed::FixedI8",
"fixed::FixedI16",
"fixed::FixedI32",
"fixed::FixedI64",
"fixed::FixedI128",
"fixed::FixedU8",
"fixed::FixedU16",
"fixed::FixedU32",
"fixed::FixedU64",
"fixed::FixedU128",
"ordered_float::OrderedFloat",
"regex::Regex",
"rust_decimal::Decimal",
"time::Date",
"time::Duration",
"time::Month",
"time::OffsetDateTime",
"time::PrimitiveDateTime",
"time::Time",
"time::UtcDateTime",
"time::Weekday",
"uuid::Uuid",
];

fn path_to_string(path: &Path) -> String {
path.segments
.iter()
Expand Down Expand Up @@ -227,10 +298,6 @@ fn should_validate_path(generics: &Generics, path: &Path) -> Option<KnownOrUnkno
let path_string = path_to_string(path);
let path_string = path_string.as_str();

if BUILT_IN_TYPES.contains(&path_string) {
return None;
}

if CONTAINER_TYPES.contains(&path_string)
&& let Some(segment) = path.segments.last()
&& let PathArguments::AngleBracketed(arguments) = &segment.arguments
Expand Down Expand Up @@ -266,6 +333,10 @@ fn should_validate_path(generics: &Generics, path: &Path) -> Option<KnownOrUnkno
return None;
}

if BUILT_IN_TYPES.contains(&path_string) || ECOSYSTEM_TYPES.contains(&path_string) {
return None;
}

let path = Punctuated::<PathSegment, PathSep>::from_iter(
path.segments
.iter()
Expand Down
1 change: 0 additions & 1 deletion packages/fortifier/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
mod error;
mod error_code;
mod integrations;
mod types;
mod validate;
mod validations;

Expand Down
6 changes: 0 additions & 6 deletions packages/fortifier/src/types.rs

This file was deleted.

40 changes: 0 additions & 40 deletions packages/fortifier/src/types/chrono.rs

This file was deleted.

9 changes: 0 additions & 9 deletions packages/fortifier/src/types/decimal.rs

This file was deleted.

9 changes: 0 additions & 9 deletions packages/fortifier/src/types/uuid.rs

This file was deleted.