import {
  IsInt,
  IsNotEmpty,
  IsObject,
  IsOptional,
  IsString,
  MaxLength,
  Min,
} from 'class-validator';

export class CreateContentBlockDto {
  @IsInt()
  activityId!: number;

  /**
   * Free-form so administrators can introduce block types without a backend
   * release; CONTENT_BLOCK_TYPES documents the ones the mobile app renders.
   */
  @IsString()
  @IsNotEmpty()
  @MaxLength(64)
  type!: string;

  @IsOptional()
  @IsString()
  @MaxLength(255)
  title?: string;

  @IsOptional()
  @IsObject()
  payload?: Record<string, any>;

  @IsOptional()
  @IsInt()
  @Min(0)
  orderIndex?: number;
}

export class UpdateContentBlockDto {
  @IsOptional()
  @IsString()
  @MaxLength(64)
  type?: string;

  @IsOptional()
  @IsString()
  @MaxLength(255)
  title?: string;

  @IsOptional()
  @IsObject()
  payload?: Record<string, any>;

  @IsOptional()
  @IsInt()
  @Min(0)
  orderIndex?: number;
}
