Skip to content

Commit 8bf2927

Browse files
docs(book): add URL validation (#27)
1 parent 840ac7a commit 8bf2927

6 files changed

Lines changed: 43 additions & 2 deletions

File tree

book/src/SUMMARY.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
- [Email](./validations/email.md)
1111
- [Length](./validations/length.md)
1212
- [Regex]()
13-
- [URL]()
13+
- [URL](./validations/url.md)
1414
- [Integrations]()
1515
- [Serde]()
1616
- [Utoipa]()

book/src/validations/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,4 @@
22

33
- [Email](./email.md)
44
- [Length](./length.md)
5+
- [URL](./url.md)

book/src/validations/email.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ Validate the string is an RFC-compliant email address.
3131

3232
Validate the value is an RFC-compliant email address.
3333

34-
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.
34+
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.
3535

3636
## Options
3737

book/src/validations/url.md

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
# URL
2+
3+
> [!NOTE]
4+
> Requires the `url` feature.
5+
6+
Validate a string is a specification-compliant URL using the [`url`](https://docs.rs/url/latest/url/) crate.
7+
8+
```rust
9+
# extern crate fortifier;
10+
# use fortifier::Validate;
11+
#
12+
##[derive(Validate)]
13+
struct User {
14+
#[validate(url)]
15+
url: String
16+
}
17+
```
18+
19+
## Types
20+
21+
### String
22+
23+
- [`str`](https://doc.rust-lang.org/std/primitive.str.html)
24+
- [`String`](https://doc.rust-lang.org/std/string/struct.String.html)
25+
26+
Validate the string is a specification-compliant URL.
27+
28+
### URL
29+
30+
- [`Url`](https://docs.rs/url/latest/url/struct.Url.html)
31+
32+
Validate the value is a specification-compliant URL.
33+
34+
A `Url` can only be constructed by parsing it, so no re-validation is performed.

packages/fortifier-macros/Cargo.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@ license.workspace = true
88
repository.workspace = true
99
version.workspace = true
1010

11+
[package.metadata.docs.rs]
12+
all-features = true
13+
1114
[lib]
1215
proc-macro = true
1316

packages/fortifier/Cargo.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@ license.workspace = true
88
repository.workspace = true
99
version.workspace = true
1010

11+
[package.metadata.docs.rs]
12+
all-features = true
13+
1114
[features]
1215
default = ["macros"]
1316
all-validations = ["email", "regex", "url"]

0 commit comments

Comments
 (0)