Files
komp_ac/server/src/auth/models.rs
2025-03-24 22:03:04 +01:00

28 lines
666 B
Rust

// src/auth/models.rs
use serde::{Deserialize, Serialize};
use validator::Validate;
#[derive(Debug, Validate, Deserialize)]
pub struct RegisterRequest {
#[validate(length(min = 1, max = 30))]
pub username: String,
#[validate(email)]
pub email: String,
#[validate(length(min = 1))]
pub password: String,
pub password_confirmation: String,
}
#[derive(Debug, thiserror::Error)]
pub enum AuthError {
#[error("Passwords do not match")]
PasswordMismatch,
#[error("User already exists")]
UserExists,
#[error("Database error: {0}")]
DatabaseError(String),
#[error("Hashing error: {0}")]
HashingError(String),
}