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
18 changes: 15 additions & 3 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ version = "0.2.11"

[workspace.dependencies]
chrono = "0.4.42"
constant-string = "0.0.2"
email_address = { version = "0.2.9", default-features = false }
fortifier = { path = "./packages/fortifier", version = "0.2.0" }
fortifier-macros = { path = "./packages/fortifier-macros", version = "0.2.0" }
Expand Down
1 change: 1 addition & 0 deletions packages/fortifier-macros-tests/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ ignored = ["chrono", "rust_decimal", "uuid"]

[dev-dependencies]
chrono.workspace = true
constant-string.workspace = true
email_address.workspace = true
fortifier = { workspace = true, features = [
"all-types",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
use fortifier::{Validate, error_code};
use constant_string::constant_string;
use fortifier::Validate;
use serde::{Deserialize, Serialize};

#[derive(Deserialize, Serialize, Validate)]
Expand Down Expand Up @@ -35,7 +36,7 @@ struct CustomData<'a> {
strip_to_two_options_from_three: Option<Option<Option<&'a str>>>,
}

error_code!(CustomErrorCode, CUSTOM_ERROR_CODE, "custom");
constant_string!(CustomErrorCode, CUSTOM_ERROR_CODE, "custom");

#[derive(Debug, Deserialize, PartialEq, Serialize)]
#[serde(rename_all = "camelCase")]
Expand Down
4 changes: 3 additions & 1 deletion packages/fortifier/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -26,16 +26,18 @@ regex = ["dep:regex"]
serde = [
"dep:serde",
"chrono?/serde",
"constant-string/serde",
"email_address?/serde_support",
"fortifier-macros?/serde",
"uuid?/serde",
]
url = ["dep:url"]
utoipa = ["dep:utoipa", "fortifier-macros?/utoipa"]
utoipa = ["dep:utoipa", "constant-string/utoipa", "fortifier-macros?/utoipa"]
uuid = ["dep:uuid"]

[dependencies]
chrono = { workspace = true, optional = true }
constant-string.workspace = true
email_address = { workspace = true, default-features = false, optional = true }
fortifier-macros = { workspace = true, optional = true }
indexmap = { workspace = true, optional = true }
Expand Down
117 changes: 0 additions & 117 deletions packages/fortifier/src/error_code.rs

This file was deleted.

1 change: 0 additions & 1 deletion packages/fortifier/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
//! Fortifier.

mod error;
mod error_code;
mod integrations;
mod validate;
mod validations;
Expand Down
5 changes: 2 additions & 3 deletions packages/fortifier/src/validations/email_address.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,11 @@ use std::{
sync::Arc,
};

use constant_string::constant_string;
use email_address::EmailAddress;
pub use email_address::Options as EmailAddressOptions;

use crate::error_code;

error_code!(
constant_string!(
EmailAddressErrorCode,
EMAIL_ADDRESS_ERROR_CODE,
"emailAddress"
Expand Down
5 changes: 2 additions & 3 deletions packages/fortifier/src/validations/length.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,11 @@ use std::{
sync::Arc,
};

use constant_string::constant_string;
#[cfg(feature = "indexmap")]
use indexmap::{IndexMap, IndexSet};

use crate::error_code;

error_code!(LengthErrorCode, LENGTH_ERROR_CODE, "length");
constant_string!(LengthErrorCode, LENGTH_ERROR_CODE, "length");

/// Length validation error.
#[derive(Debug, Eq, PartialEq)]
Expand Down
5 changes: 2 additions & 3 deletions packages/fortifier/src/validations/phone_number.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,11 @@ use std::{
sync::Arc,
};

use constant_string::constant_string;
pub use phonenumber::country::Id as PhoneNumberCountry;
use phonenumber::{ParseError, PhoneNumber};

use crate::error_code;

error_code!(PhoneNumberErrorCode, PHONE_NUMBER_ERROR_CODE, "phoneNumber");
constant_string!(PhoneNumberErrorCode, PHONE_NUMBER_ERROR_CODE, "phoneNumber");

/// Phone number validation error.
#[derive(Debug, Eq, PartialEq)]
Expand Down
4 changes: 2 additions & 2 deletions packages/fortifier/src/validations/range.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ use std::{
sync::Arc,
};

use crate::error_code;
use constant_string::constant_string;

error_code!(RangeErrorCode, RANGE_ERROR_CODE, "range");
constant_string!(RangeErrorCode, RANGE_ERROR_CODE, "range");

/// Range validation error.
#[derive(Debug, Eq, PartialEq)]
Expand Down
5 changes: 2 additions & 3 deletions packages/fortifier/src/validations/regex.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,9 @@ use std::{
sync::{Arc, LazyLock},
};

use constant_string::constant_string;
use regex::Regex;

use crate::error_code;

/// Convert to a regular expression.
pub trait AsRegex {
/// Convert to a regular expression.
Expand Down Expand Up @@ -38,7 +37,7 @@ where
}
}

error_code!(RegexErrorCode, REGEX_ERROR_CODE, "regex");
constant_string!(RegexErrorCode, REGEX_ERROR_CODE, "regex");

/// Regular expression validation error.
#[derive(Debug, Eq, PartialEq)]
Expand Down
5 changes: 2 additions & 3 deletions packages/fortifier/src/validations/url.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,10 @@ use std::{
sync::Arc,
};

use constant_string::constant_string;
use url::{ParseError, Url};

use crate::error_code;

error_code!(UrlErrorCode, URL_ERROR_CODE, "url");
constant_string!(UrlErrorCode, URL_ERROR_CODE, "url");

/// URL validation error.
#[derive(Debug, Eq, PartialEq)]
Expand Down
Loading