-
Notifications
You must be signed in to change notification settings - Fork 55
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
seperate regex to new validation.rs util
Signed-off-by: blu3beri <[email protected]>
- Loading branch information
blu3beri
committed
Jan 11, 2023
1 parent
12e79c2
commit 667ecb3
Showing
5 changed files
with
34 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
/// Functions for quick validation | ||
pub mod validation; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
use once_cell::sync::Lazy; | ||
use regex::Regex; | ||
|
||
// TODO: stricten the URI regex. | ||
// Right now everything after the first colon is allowed, | ||
// we might want to restrict this | ||
pub const URI_IDENTIFIER: Lazy<Regex> = | ||
Lazy::new(|| Regex::new(r"^[a-zA-Z0-9\+\-\.]+:.+$").unwrap()); | ||
|
||
/// base58 alpahet as defined in | ||
/// https://datatracker.ietf.org/doc/html/draft-msporny-base58#section-2 | ||
/// This is used for legacy indy identifiers that we will keep supporting for | ||
/// backwards compatibility. This might validate invalid identifiers if they happen | ||
/// to fall within the base58 alphabet, but there is not much we can do about that. | ||
pub const LEGACY_IDENTIFIER: Lazy<Regex> = | ||
Lazy::new(|| Regex::new("^[1-9A-HJ-NP-Za-km-z]{21,22}$").unwrap()); |