// src/auth/models.rs

use serde::Deserialize;
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, Validate, Deserialize)]
pub struct LoginRequest {
    #[validate(length(min = 1))]
    pub identifier: String,
    #[validate(length(min = 1))]
    pub password: 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),
    #[error("Invalid credentials")]
    InvalidCredentials,
    #[error("JWT error: {0}")]
    JwtError(String),
    #[error("Configuration error: {0}")]
    ConfigError(String),
}
