Please check the build logs for more information.
See Builds for ideas on how to fix a failed build, or Metadata for how to configure docs.rs builds.
If you believe this is docs.rs' fault, open an issue.
sanitizer
Inspired by the validator crate. The Sanitizer crate is a collection of methods and a macro to sanitize struct fields, leveraging the macros of rust, it follows the elegant approach by the validator crate.
Overview
sanitizer =
Then to use the crate
use *;
If you do not want to use the derive macro, then the sanitizer crate provides structures and methods for sanitizing ints
let int: u8 = 50;
let mut instance = from;
instance.clamp;
assert_eq!;
and strings
let mut sanitize = from;
sanitize.trim.numeric;
assert_eq!;
Sanitizers
trim
Removes whitespace from ends.
numeric
Removes any character that is not a numeric.
alphanumeric
Removes any character that is not an alphanumeric.
lower_case
Converts string input to lowercase.
upper_case
Converts string input to UPPERCASE.
camel_case
Converts string input to camelCase.
snake_case
Converts string input to snake_case.
screaming_snake_case
Converts string input to SCREAMING_SNAKE_CASE using the Inflector crate.
e164
Converts string input to E164 International Phone Number format. This panics if the phone number is not a valid one.
clamp(min, max)
Limit an valid integer field with the given min and max.
clamp(max)
Limit a string input length to the following number
custom(function)
Use a custom function to sanitize a field differently. For example
nesting
The sanitize method of First will call the sanitizer method of OtherInfo automatically,
if you would like to individually snaitize OtherInfo then you can just call snaitize on one of its instance.
LICENSE
dashxhq/sanitizer is licensed under the MIT License.