diff --git a/book/src/SUMMARY.md b/book/src/SUMMARY.md index ca799c0..31203a2 100644 --- a/book/src/SUMMARY.md +++ b/book/src/SUMMARY.md @@ -10,7 +10,7 @@ - [Email](./validations/email.md) - [Length](./validations/length.md) - [Regex]() - - [URL]() + - [URL](./validations/url.md) - [Integrations]() - [Serde]() - [Utoipa]() diff --git a/book/src/validations/README.md b/book/src/validations/README.md index 13243ad..c17969b 100644 --- a/book/src/validations/README.md +++ b/book/src/validations/README.md @@ -2,3 +2,4 @@ - [Email](./email.md) - [Length](./length.md) +- [URL](./url.md) diff --git a/book/src/validations/email.md b/book/src/validations/email.md index 276e116..b5df3ba 100644 --- a/book/src/validations/email.md +++ b/book/src/validations/email.md @@ -31,7 +31,7 @@ Validate the string is an RFC-compliant email address. Validate the value is an RFC-compliant email address. -An `EmailAddress` can be constructed using [`EmailAddress::new_unchecked`](https://docs.rs/email_address/latest/email_address/struct.EmailAddress.html#method.new_unchecked) or with different options passed to [`EmailAddress::parse_with_options`](https://docs.rs/email_address/latest/email_address/struct.EmailAddress.html#method.parse_with_options), so it has to be re-validated. +An `EmailAddress` can be constructed using [`EmailAddress::new_unchecked`](https://docs.rs/email_address/latest/email_address/struct.EmailAddress.html#method.new_unchecked) or with different options passed to [`EmailAddress::parse_with_options`](https://docs.rs/email_address/latest/email_address/struct.EmailAddress.html#method.parse_with_options), so re-validation is required. ## Options diff --git a/book/src/validations/url.md b/book/src/validations/url.md new file mode 100644 index 0000000..ad8c147 --- /dev/null +++ b/book/src/validations/url.md @@ -0,0 +1,34 @@ +# URL + +> [!NOTE] +> Requires the `url` feature. + +Validate a string is a specification-compliant URL using the [`url`](https://docs.rs/url/latest/url/) crate. + +```rust +# extern crate fortifier; +# use fortifier::Validate; +# +##[derive(Validate)] +struct User { + #[validate(url)] + url: String +} +``` + +## Types + +### String + +- [`str`](https://doc.rust-lang.org/std/primitive.str.html) +- [`String`](https://doc.rust-lang.org/std/string/struct.String.html) + +Validate the string is a specification-compliant URL. + +### URL + +- [`Url`](https://docs.rs/url/latest/url/struct.Url.html) + +Validate the value is a specification-compliant URL. + +A `Url` can only be constructed by parsing it, so no re-validation is performed. diff --git a/packages/fortifier-macros/Cargo.toml b/packages/fortifier-macros/Cargo.toml index a5020f8..6a99e51 100644 --- a/packages/fortifier-macros/Cargo.toml +++ b/packages/fortifier-macros/Cargo.toml @@ -8,6 +8,9 @@ license.workspace = true repository.workspace = true version.workspace = true +[package.metadata.docs.rs] +all-features = true + [lib] proc-macro = true diff --git a/packages/fortifier/Cargo.toml b/packages/fortifier/Cargo.toml index a54b8f0..fc2295e 100644 --- a/packages/fortifier/Cargo.toml +++ b/packages/fortifier/Cargo.toml @@ -8,6 +8,9 @@ license.workspace = true repository.workspace = true version.workspace = true +[package.metadata.docs.rs] +all-features = true + [features] default = ["macros"] all-validations = ["email", "regex", "url"]