fix(core/models): validator feature flag not properly gatekept

This commit is contained in:
Paul Makles
2023-10-20 18:16:12 +01:00
committed by Paul Makles
parent 29dcf714f2
commit 96d90215d2
3 changed files with 11 additions and 5 deletions

View File

@@ -1,3 +1,4 @@
#[cfg(feature = "validator")]
use validator::Validate;
use super::File;
@@ -80,7 +81,7 @@ auto_derived!(
}
/// Information for the webhook
#[derive(Validate)]
#[cfg_attr(feature = "validator", derive(Validate))]
pub struct CreateWebhookBody {
#[validate(length(min = 1, max = 32))]
pub name: String,

View File

@@ -1,5 +1,7 @@
use once_cell::sync::Lazy;
use regex::Regex;
#[cfg(feature = "validator")]
use validator::Validate;
/// Regex for valid emoji names
@@ -41,7 +43,7 @@ auto_derived!(
}
/// Create a new emoji
#[derive(Validate)]
#[cfg_attr(feature = "validator", derive(Validate))]
pub struct DataCreateEmoji {
/// Server name
#[validate(length(min = 1, max = 32), regex = "RE_EMOJI")]

View File

@@ -6,6 +6,8 @@ use std::{
use once_cell::sync::Lazy;
use regex::Regex;
use revolt_config::config;
#[cfg(feature = "validator")]
use validator::Validate;
use iso8601_timestamp::Timestamp;
@@ -94,7 +96,7 @@ auto_derived!(
}
/// Name and / or avatar override information
#[derive(Validate)]
#[cfg_attr(feature = "validator", derive(Validate))]
pub struct Masquerade {
// FIXME: missing validation
/// Replace the display name shown on this message
@@ -164,7 +166,8 @@ auto_derived!(
}
/// Representation of a text embed before it is sent.
#[derive(Default, Validate)]
#[derive(Default)]
#[cfg_attr(feature = "validator", derive(Validate))]
pub struct SendableEmbed {
#[validate(length(min = 1, max = 128))]
pub icon_url: Option<String>,
@@ -188,7 +191,7 @@ auto_derived!(
}
/// Message to send
#[derive(Validate)]
#[cfg_attr(feature = "validator", derive(Validate))]
pub struct DataMessageSend {
/// Unique token to prevent duplicate message sending
///