import { IsNotEmpty, IsString, MinLength } from 'class-validator';
import { ApiProperty } from '@nestjs/swagger';

/**
 * VerifyAccountRequestDto - Data Transfer Object for account verification and password setup
 *
 * This DTO handles the final step of account verification where users:
 * 1. Provide a verification token received via email or SMS
 * 2. Set their initial password for the newly created account
 *
 * Typical use cases:
 * - Email verification after registration
 * - Account activation for invited users
 * - Password setup for accounts created by administrators
 *
 * @example
 * // Complete account verification
 * {
 *   "token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...",
 *   "password": "SecurePass123!"
 * }
 *
 * @example
 * // Usage in controller
 * @Post('verify-account')
 * verifyAccount(@Body() verifyAccountDto: VerifyAccountRequestDto) {
 *   return this.authService.verifyAndActivateAccount(verifyAccountDto);
 * }
 */
export class VerifyAccountRequestDto {
  /**
   * Account verification token
   *
   * A secure token that validates the account verification request.
   * Typically generated during account creation/invitation and sent to the user.
   *
   * Token characteristics:
   * - Time-limited (usually expires in 24-72 hours)
   * - Single-use (invalidated after successful verification)
   * - Cryptographically signed to prevent tampering
   * - Tied to a specific user account
   *
   * Security considerations:
   * - Validate token signature and expiration
   * - Check token hasn't been used already
   * - Ensure token matches the intended user
   * - Log verification attempts for security monitoring
   *
   * Validation rules:
   * - Must be a non-empty string
   *
   * @example "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9..."
   * @example "abc123def456ghi789"
   */
  @IsString()
  @IsNotEmpty()
  @ApiProperty({
    description: 'Account verification token',
    example: 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...',
    required: true,
  })
  token: string;

  /**
   * Initial account password
   *
   * The password to set for the newly verified account.
   * This establishes the user's authentication credentials.
   *
   * Security requirements:
   * - Minimum 8 characters (consider 12+ for better security)
   * - Should meet password complexity requirements
   * - Should be hashed before storage
   * - Should be checked against breached password databases
   *
   * Validation rules:
   * - Must be a string
   * - Minimum 8 characters
   * - Must be non-empty
   *
   * @warning Consider adding complexity validation:
   *   @Matches(/(?=.*[a-z])(?=.*[A-Z])(?=.*\d)/)
   *
   * @example "SecurePass123!"
   * @example "VeryStrongPassword456@"
   */
  @IsString()
  @MinLength(8)
  @IsNotEmpty()
  @ApiProperty({
    description: 'Initial account password (minimum 8 characters)',
    example: 'SecurePass123!',
    minLength: 8,
    required: true,
  })
  password: string;
}
