chore: migrate bots create route

This commit is contained in:
Paul Makles
2023-08-05 11:24:02 +01:00
parent 42f977f536
commit c9011ac692
16 changed files with 272 additions and 35 deletions

View File

@@ -1,7 +1,10 @@
use super::User;
use validator::Validate;
auto_derived!(
/// Bot
#[derive(Default)]
pub struct Bot {
/// Bot Id
#[cfg_attr(feature = "serde", serde(rename = "_id"))]
@@ -87,12 +90,13 @@ auto_derived!(
}
/// Bot Details
#[cfg_attr(feature = "validator", derive(Validate))]
pub struct DataCreateBot {
/// Bot username
#[cfg_attr(
feature = "validator",
validate(length(min = 2, max = 32), regex = "RE_USERNAME")
validate(length(min = 2, max = 32), regex = "super::RE_USERNAME")
)]
name: String,
pub name: String,
}
);

View File

@@ -1,5 +1,14 @@
use once_cell::sync::Lazy;
use regex::Regex;
use super::File;
/// Regex for valid usernames
///
/// Block zero width space
/// Block lookalike characters
pub static RE_USERNAME: Lazy<Regex> = Lazy::new(|| Regex::new(r"^(\p{L}|[\d_.-])+$").unwrap());
auto_derived!(
/// User
pub struct User {