import { IsString, IsNotEmpty, IsOptional, IsInt, Matches, IsIn } from 'class-validator';

export class CreateStudentDto {
  @IsString()
  @IsNotEmpty({ message: '姓名不能为空' })
  name: string;

  @IsOptional()
  @IsIn(['男', '女'], { message: '性别只能是男或女' })
  gender?: string;

  @IsOptional()
  @IsString()
  birthDate?: string;

  @IsInt()
  @IsNotEmpty({ message: '班级不能为空' })
  classId: number;

  @IsOptional()
  @IsString()
  parentName?: string;

  @IsOptional()
  @IsString()
  @Matches(/^1[3-9]\d{9}$/, { message: '请输入正确的手机号' })
  parentPhone?: string;
}

export class UpdateStudentDto {
  @IsOptional()
  @IsString()
  @IsNotEmpty({ message: '姓名不能为空' })
  name?: string;

  @IsOptional()
  @IsIn(['男', '女'], { message: '性别只能是男或女' })
  gender?: string;

  @IsOptional()
  @IsString()
  birthDate?: string;

  @IsOptional()
  @IsInt()
  classId?: number;

  @IsOptional()
  @IsString()
  parentName?: string;

  @IsOptional()
  @IsString()
  @Matches(/^1[3-9]\d{9}$/, { message: '请输入正确的手机号' })
  parentPhone?: string;
}
