export interface SignupFormData { displayName: string; email: string; password: string; confirmPassword: string; } export interface SignupValidationErrors { displayName?: string; email?: string; password?: string; confirmPassword?: string; } /** * SignupCommandModel * * Encapsulates signup form state, client-side validation, and * prepares data for submission to the AuthService. */ export class SignupCommandModel { private _displayName: string; private _email: string; private _password: string; private _confirmPassword: string; constructor(initial: SignupFormData) { this._displayName = initial.displayName; this._email = initial.email; this._password = initial.password; this._confirmPassword = initial.confirmPassword; } get displayName(): string { return this._displayName; } get email(): string { return this._email; } get password(): string { return this._password; } get confirmPassword(): string { return this._confirmPassword; } /** Basic client-side validation for signup form */ validate(): SignupValidationErrors { const errors: SignupValidationErrors = {}; if (!this._displayName.trim()) { errors.displayName = 'Display name is required'; } else if (this._displayName.trim().length < 3) { errors.displayName = 'Display name must be at least 3 characters'; } if (!this._email.trim()) { errors.email = 'Email is required'; } else if (!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(this._email)) { errors.email = 'Invalid email format'; } if (!this._password) { errors.password = 'Password is required'; } else if (this._password.length < 8) { errors.password = 'Password must be at least 8 characters'; } if (!this._confirmPassword) { errors.confirmPassword = 'Please confirm your password'; } else if (this._password !== this._confirmPassword) { errors.confirmPassword = 'Passwords do not match'; } return errors; } /** Convert to API SignupParams DTO */ toRequestDto(): { email: string; password: string; displayName: string } { return { email: this._email, password: this._password, displayName: this._displayName, }; } }