import { IsString, Matches, Length, MinLength } from 'class-validator';
import { isValidIranMobile } from '../../../common/utils/mobile.util';
import { ErrorCode } from '../../../common/errors';

export class ForgotPasswordSendCodeDto {
  @IsString()
  @Matches(/^[\d+\s()-]+$/, { message: ErrorCode.VALIDATION_MOBILE_INVALID })
  mobile: string;

  static validateMobile(mobile: string): boolean {
    return isValidIranMobile(mobile);
  }
}

export class ForgotPasswordVerifyDto {
  @IsString()
  @Matches(/^[\d+\s()-]+$/, { message: ErrorCode.VALIDATION_MOBILE_INVALID })
  mobile: string;

  @IsString()
  @Length(5, 6, { message: ErrorCode.VALIDATION_FIELD_REQUIRED })
  code: string;
}
