Is there a way to use variables in error messages?
use serde::{Deserialize, Serialize};
use validator::Validate;
use crate::features::auth::constants::{
FIRST_NAME_MAX_LENGTH, FIRST_NAME_MIN_LENGTH, LAST_NAME_MAX_LENGTH, LAST_NAME_MIN_LENGTH,
PASSWORD_MAX_LENGTH, PASSWORD_MIN_LENGTH,
};
#[derive(Deserialize, Serialize, Validate)]
pub struct SignUpRequest {
#[validate(email(message = "Invalid email address format"))]
pub email: String,
#[validate(
length(min = PASSWORD_MIN_LENGTH, max = PASSWORD_MAX_LENGTH, message = "Password must be between {min} and {max} characters")
)]
pub password: String,
#[validate(
length(min = FIRST_NAME_MIN_LENGTH, max = FIRST_NAME_MAX_LENGTH, message = "First name must be between {min} and {max} characters")
)]
pub first_name: String,
#[validate(
length(min = LAST_NAME_MIN_LENGTH, max = LAST_NAME_MAX_LENGTH, message = "Last name must be between {min} and {max} characters")
)]
pub last_name: String,
}
Is there a way to use variables in error messages?