moved all RE_USERNAME occurrences to regex.rs

switch to normal Cargo.toml

switch to normal Cargo.toml

switch to normal Cargo.toml

solved bug
This commit is contained in:
meguminloli
2021-09-15 20:48:23 +03:00
parent 2660b96250
commit a2bfaa5791
8 changed files with 98 additions and 82 deletions

View File

@@ -1,21 +1,15 @@
use crate::database::*;
use crate::util::result::{Error, Result};
use crate::util::variables::MAX_BOT_COUNT;
use crate::util::regex::RE_USERNAME;
use mongodb::bson::{doc, to_document};
use regex::Regex;
use rocket::serde::json::{Json, Value};
use serde::{Deserialize, Serialize};
use ulid::Ulid;
use nanoid::nanoid;
use validator::Validate;
// ! FIXME: should be global somewhere; maybe use config(?)
// ! tip: CTRL + F, RE_USERNAME
lazy_static! {
static ref RE_USERNAME: Regex = Regex::new(r"^[a-zA-Z0-9_.]+$").unwrap();
}
#[derive(Validate, Serialize, Deserialize)]
pub struct Data {
#[validate(length(min = 2, max = 32), regex = "RE_USERNAME")]