Skip to content

Commit

Permalink
Remove phone feature and code
Browse files Browse the repository at this point in the history
  • Loading branch information
Keats committed May 13, 2023
1 parent 61531d3 commit 897811a
Show file tree
Hide file tree
Showing 10 changed files with 3 additions and 157 deletions.
2 changes: 0 additions & 2 deletions validator/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,11 @@ serde_derive = "1"
serde_json = "1"
validator_derive = { version = "0.16", path = "../validator_derive", optional = true }
card-validate = { version = "2.2", optional = true }
phonenumber = { version = "0.3", optional = true }
unic-ucd-common = { version = "0.9", optional = true }
indexmap = {version = "1", features = ["serde-1"], optional = true }


[features]
phone = ["phonenumber", "validator_derive/phone"]
card = ["card-validate", "validator_derive/card"]
unic = ["unic-ucd-common", "validator_derive/unic"]
derive = ["validator_derive"]
2 changes: 0 additions & 2 deletions validator/src/validation/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@ pub mod length;
pub mod must_match;
#[cfg(feature = "unic")]
pub mod non_control_character;
#[cfg(feature = "phone")]
pub mod phone;
pub mod range;
pub mod required;
pub mod urls;
51 changes: 0 additions & 51 deletions validator/src/validation/phone.rs

This file was deleted.

1 change: 0 additions & 1 deletion validator_derive/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ readme = "../README.md"
proc-macro = true

[features]
phone = ["validator_types/phone"]
card = ["validator_types/card"]
unic = ["validator_types/unic"]

Expand Down
8 changes: 1 addition & 7 deletions validator_derive/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -404,7 +404,7 @@ fn find_validators_for_field(
for meta_item in meta_items {
match *meta_item {
syn::NestedMeta::Meta(ref item) => match *item {
// email, url, phone, credit_card, non_control_character
// email, url, credit_card, non_control_character
syn::Meta::Path(ref name) => {
match name.get_ident().unwrap().to_string().as_ref() {
"email" => {
Expand All @@ -413,11 +413,6 @@ fn find_validators_for_field(
"url" => {
validators.push(FieldValidation::new(Validator::Url));
}
#[cfg(feature = "phone")]
"phone" => {
assert_string_type("phone", field_type, &field.ty);
validators.push(FieldValidation::new(Validator::Phone));
}
#[cfg(feature = "card")]
"credit_card" => {
assert_string_type("credit_card", field_type, &field.ty);
Expand Down Expand Up @@ -528,7 +523,6 @@ fn find_validators_for_field(
}
"email"
| "url"
| "phone"
| "credit_card"
| "non_control_character"
| "required" => {
Expand Down
22 changes: 0 additions & 22 deletions validator_derive/src/quoting.rs
Original file line number Diff line number Diff line change
Expand Up @@ -309,26 +309,6 @@ pub fn quote_credit_card_validation(
field_quoter.wrap_if_option(quoted)
}

#[cfg(feature = "phone")]
pub fn quote_phone_validation(
field_quoter: &FieldQuoter,
validation: &FieldValidation,
) -> proc_macro2::TokenStream {
let field_name = &field_quoter.name;
let validator_param = field_quoter.quote_validator_param();

let quoted_error = quote_error(validation);
let quoted = quote!(
if !::validator::validate_phone(#validator_param) {
#quoted_error
err.add_param(::std::borrow::Cow::from("value"), &#validator_param);
errors.add(#field_name, err);
}
);

field_quoter.wrap_if_option(quoted)
}

#[cfg(feature = "unic")]
pub fn quote_non_control_character_validation(
field_quoter: &FieldQuoter,
Expand Down Expand Up @@ -539,8 +519,6 @@ pub fn quote_validator(
Validator::CreditCard => {
validations.push(quote_credit_card_validation(field_quoter, validation))
}
#[cfg(feature = "phone")]
Validator::Phone => validations.push(quote_phone_validation(field_quoter, validation)),
Validator::Nested => nested_validations.push(quote_nested_validation(field_quoter)),
#[cfg(feature = "unic")]
Validator::NonControlCharacter => {
Expand Down
4 changes: 1 addition & 3 deletions validator_derive/src/validation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,7 @@ pub fn extract_custom_validation(
}
}

/// Extract url/email/phone/non_control_character field validation with a code or a message
/// Extract url/email/non_control_character field validation with a code or a message
pub fn extract_argless_validation(
validator_name: String,
field: String,
Expand Down Expand Up @@ -335,8 +335,6 @@ pub fn extract_argless_validation(
"email" => Validator::Email,
#[cfg(feature = "card")]
"credit_card" => Validator::CreditCard,
#[cfg(feature = "phone")]
"phone" => Validator::Phone,
#[cfg(feature = "unic")]
"non_control_character" => Validator::NonControlCharacter,
"required" => Validator::Required,
Expand Down
2 changes: 1 addition & 1 deletion validator_derive_tests/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ authors = ["Vincent Prouillet <hello@vincentprouillet.com>"]
edition = "2018"

[dev-dependencies]
validator = { version = "0.16", path = "../validator", features = ["phone", "card", "unic", "derive", "indexmap"] }
validator = { version = "0.16", path = "../validator", features = ["card", "unic", "derive", "indexmap"] }
serde = { version = "1.0", features = ["derive"] }
serde_json = "1.0"
trybuild = "1.0"
Expand Down
67 changes: 0 additions & 67 deletions validator_derive_tests/tests/phone.rs

This file was deleted.

1 change: 0 additions & 1 deletion validator_types/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ readme = "../README.md"


[features]
phone = []
card = []
unic = []

Expand Down

0 comments on commit 897811a

Please sign in to comment.