chore: migrate bots create route
This commit is contained in:
@@ -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,
|
||||
}
|
||||
);
|
||||
|
||||
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user