mirror of
https://gitlab.com/comunic/comunicapiv3
synced 2025-06-21 00:45:18 +00:00
Can create YouTube posts
This commit is contained in:
@ -50,4 +50,25 @@ pub fn check_url(url: &str) -> bool {
|
||||
/// ```
|
||||
pub fn check_string_before_insert(s: &str) -> bool {
|
||||
s.trim().len() > 3
|
||||
}
|
||||
|
||||
/// Check the validity of a YouTube ID
|
||||
///
|
||||
/// ```
|
||||
/// use comunic_server::utils::string_utils::check_youtube_id;
|
||||
///
|
||||
/// assert_eq!(check_youtube_id("/ab/"), false);
|
||||
/// assert_eq!(check_youtube_id("abxZ96C"), true);
|
||||
/// assert_eq!(check_youtube_id("a6C"), false);
|
||||
/// ```
|
||||
pub fn check_youtube_id(id: &str) -> bool {
|
||||
id.len() >= 5
|
||||
&& !id.contains("/")
|
||||
&& !id.contains("\\")
|
||||
&& !id.contains("@")
|
||||
&& !id.contains("&")
|
||||
&& !id.contains("?")
|
||||
&& !id.contains(".")
|
||||
&& !id.contains("'")
|
||||
&& !id.contains("\"")
|
||||
}
|
Reference in New Issue
Block a user