import { IsEnum, IsNotEmpty, IsOptional, IsString, IsBoolean, IsNumber, Min, IsInt } from "class-validator";
import { ProductCategory } from "../../../enums/product-categories.enum";
import { ProductUOM } from "../../../enums/product-uom.enum";

export class ProductDTO {
    @IsOptional()
    id?: string;

    @IsString()
    @IsNotEmpty()
    name: string;

    @IsString()
    @IsNotEmpty()
    brand: string;

    @IsInt()
    @IsEnum(ProductCategory, { message: "Invalid category" })
    category: ProductCategory;

    /**
     * Properties worked on by a restriction service
     */
    @IsOptional()
    @IsString()
    regulationType?: string;

    @IsOptional()
    @IsNumber()
    @Min(0)
    minimumAge?: number;

    @IsOptional()
    @IsBoolean()
    requiresVerification?: boolean;
    /**
     * Properties worked on by a restriction service
     */

    @IsOptional()
    @IsBoolean()
    isWeighable?: boolean;

    @IsNumber()
    @Min(0)
    quantity: number;

    @IsOptional()
    @IsNumber()
    @Min(0)
    weight?: number;

    @IsInt()
    @IsEnum(ProductUOM, { message: "Invalid unit of measurement" })
    uom: ProductUOM;

    @IsString()
    @IsNotEmpty()
    upc: string;

    @IsString()
    @IsNotEmpty()
    sku: string;
}
