forked from jmug/stoatchat
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:
@@ -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")]
|
||||
|
||||
@@ -1,19 +1,13 @@
|
||||
use crate::notifications::events::ClientboundNotification;
|
||||
use crate::util::result::{Error, Result, EmptyResponse};
|
||||
use crate::{database::*, notifications::events::RemoveBotField};
|
||||
use crate::util::regex::RE_USERNAME;
|
||||
|
||||
use mongodb::bson::doc;
|
||||
use regex::Regex;
|
||||
use rocket::serde::json::Json;
|
||||
use serde::{Deserialize, Serialize};
|
||||
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")]
|
||||
|
||||
@@ -1,17 +1,13 @@
|
||||
use crate::database::*;
|
||||
use crate::util::result::{Error, Result, EmptyResponse};
|
||||
use crate::util::regex::RE_USERNAME;
|
||||
|
||||
use mongodb::bson::doc;
|
||||
use rauth::entities::Session;
|
||||
use regex::Regex;
|
||||
use rocket::serde::json::Json;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use validator::Validate;
|
||||
|
||||
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")]
|
||||
|
||||
@@ -1,20 +1,13 @@
|
||||
use crate::database::*;
|
||||
use crate::notifications::events::ClientboundNotification;
|
||||
use crate::util::result::{Error, Result, EmptyResponse};
|
||||
|
||||
use crate::util::regex::RE_USERNAME;
|
||||
use mongodb::bson::doc;
|
||||
use rauth::entities::Account;
|
||||
use regex::Regex;
|
||||
use rocket::serde::json::Json;
|
||||
use serde::{Deserialize, Serialize};
|
||||
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")]
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
pub mod result;
|
||||
pub mod variables;
|
||||
pub mod ratelimit;
|
||||
pub mod regex;
|
||||
4
src/util/regex.rs
Normal file
4
src/util/regex.rs
Normal file
@@ -0,0 +1,4 @@
|
||||
use once_cell::sync::Lazy;
|
||||
use regex::Regex;
|
||||
|
||||
pub static RE_USERNAME: Lazy<Regex> = Lazy::new(|| Regex::new(r"^[a-zA-Z0-9_.]+$").unwrap());
|
||||
Reference in New Issue
Block a user