Skip to content

Commit 7a4b035

Browse files
authored
refactor: remove dependency on unic-ucd-common by using std::char::is_control (#366)
1 parent 32e49fb commit 7a4b035

File tree

7 files changed

+4
-14
lines changed

7 files changed

+4
-14
lines changed

.github/workflows/ci.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@ jobs:
2424
run: |
2525
cargo build --no-default-features
2626
cargo test --no-default-features
27-
cargo build --features unic --features derive --features card
28-
cargo test --features unic --features derive --features card
27+
cargo build --features derive --features card
28+
cargo test --features derive --features card
2929
test_validator-nightly:
3030
name: Continuous integration
3131
runs-on: ubuntu-latest

README.md

-1
Original file line numberDiff line numberDiff line change
@@ -335,7 +335,6 @@ Examples:
335335

336336
### non_control_character
337337
Tests whether the String has any utf-8 control characters, fails validation if it does.
338-
To use this validator, you must enable the `unic` feature for the `validator` crate.
339338
This validator doesn't take any arguments: `#[validate(non_control_character)]`;
340339

341340
### required

validator/Cargo.toml

-2
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,9 @@ serde_derive = "1"
2121
serde_json = "1"
2222
validator_derive = { version = "0.20", path = "../validator_derive", optional = true }
2323
card-validate = { version = "2.3", optional = true }
24-
unic-ucd-common = { version = "0.9", optional = true }
2524
indexmap = { version = "2.0.0", features = ["serde"], optional = true }
2625

2726
[features]
2827
card = ["card-validate"]
29-
unic = ["unic-ucd-common"]
3028
derive = ["validator_derive"]
3129
derive_nightly_features = ["derive","validator_derive/nightly_features"]

validator/src/lib.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@
4747
//! | `custom` | |
4848
//! | `regex` | |
4949
//! | `credit_card` | (Requires the feature `card` to be enabled) |
50-
//! | `non_control_character` | (Required the feature `unic` to be enabled) |
50+
//! | `non_control_character` | |
5151
//! | `required` | |
5252
//!
5353
//! [Checkout the project README of an in-depth usage description with examples.](https://github.com/Keats/validator/blob/master/README.md)
@@ -73,7 +73,6 @@ pub use validation::email::ValidateEmail;
7373
pub use validation::ip::ValidateIp;
7474
pub use validation::length::ValidateLength;
7575
pub use validation::must_match::validate_must_match;
76-
#[cfg(feature = "unic")]
7776
pub use validation::non_control_character::ValidateNonControlCharacter;
7877
pub use validation::range::ValidateRange;
7978
pub use validation::regex::{AsRegex, ValidateRegex};

validator/src/validation/mod.rs

-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ pub mod ip;
77
pub mod length;
88
pub mod must_match;
99
// pub mod nested;
10-
#[cfg(feature = "unic")]
1110
pub mod non_control_character;
1211
pub mod range;
1312
pub mod regex;

validator/src/validation/non_control_character.rs

+1-5
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
1-
#[cfg(feature = "unic")]
2-
use unic_ucd_common::control;
3-
41
pub trait ValidateNonControlCharacter {
52
fn validate_non_control_character(&self) -> bool {
6-
self.as_non_control_character_iterator().all(|code| !control::is_control(code))
3+
self.as_non_control_character_iterator().all(|code| !code.is_control())
74
}
85

96
fn as_non_control_character_iterator(&self) -> Box<dyn Iterator<Item = char> + '_>;
@@ -16,7 +13,6 @@ impl<T: AsRef<str>> ValidateNonControlCharacter for T {
1613
}
1714

1815
#[cfg(test)]
19-
#[cfg(feature = "unic")]
2016
mod tests {
2117
use super::ValidateNonControlCharacter;
2218
use std::borrow::Cow;

validator_derive_tests/Cargo.toml

-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ nightly = []
1313
[dev-dependencies]
1414
validator = { version = "0.20", path = "../validator", features = [
1515
"card",
16-
"unic",
1716
"derive",
1817
"indexmap",
1918
] }

0 commit comments

Comments
 (0)