import { ApiProperty } from "@nestjs/swagger";
import { MinLength, MaxLength, Matches, IsString, IsIn, IsOptional } from 'class-validator';

export class UserDtoCreate {

    @ApiProperty(
        {
            description: "Codice utente"
        }
    )
    @MaxLength(100)
    @IsString()
    code?: string;

    @ApiProperty(
        {
            description: "Titolo dell'utente"
        }
    )
    @MaxLength(100)
    @IsString()
    title?: string;

    @ApiProperty(
        {
            description: "Titolo dell'utente"
        }
    )
    @MaxLength(20)
    @MinLength(8)
    @IsString()
    @Matches(/^\S+$/)
    username?: string;

    @ApiProperty(
        {
            description: "Password utente"
        }
    )
    @Matches(/^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)(?=.*[!@#$%^&*()_\-+=\[\]{};:'"\\|,.<>/?`~]).{8,}$/)
    @IsString()
    password?: string;

    @ApiProperty()
    @IsIn([undefined, null, 0, 1])
    @IsOptional()
    pArticle?: number;

    @ApiProperty()
    @IsIn([undefined, null, 0, 1])
    @IsOptional()
    pAttribute?: number;

    @ApiProperty()
    @IsIn([undefined, null, 0, 1])
    @IsOptional()
    pCategory?: number;

    @ApiProperty()
    @IsIn([undefined, null, 0, 1])
    @IsOptional()
    pCreditNoteCounter?: number;

    @ApiProperty()
    @IsIn([undefined, null, 0, 1])
    @IsOptional()
    pCustomer?: number;

    @ApiProperty()
    @IsIn([undefined, null, 0, 1])
    @IsOptional()
    pDevice?: number;

    @ApiProperty()
    @IsIn([undefined, null, 0, 1])
    @IsOptional()
    pDocument?: number;

    @ApiProperty()
    @IsIn([undefined, null, 0, 1])
    @IsOptional()
    pEvent?: number;

    @ApiProperty()
    @IsIn([undefined, null, 0, 1])
    @IsOptional()
    pInvoiceCounter?: number;

    @ApiProperty()
    @IsIn([undefined, null, 0, 1])
    @IsOptional()
    pMovement?: number;
    
    @ApiProperty()
    @IsIn([undefined, null, 0, 1])
    @IsOptional()
    pOperator?: number;

    @ApiProperty()
    @IsIn([undefined, null, 0, 1])
    @IsOptional()
    pPayment?: number;

    @ApiProperty()
    @IsIn([undefined, null, 0, 1])
    @IsOptional()
    pPrice?: number;

    @ApiProperty()
    @IsIn([undefined, null, 0, 1])
    @IsOptional()
    pRate?: number;

    @ApiProperty()
    @IsIn([undefined, null, 0, 1])
    @IsOptional()
    pStorage?: number;

    @ApiProperty()
    @IsIn([undefined, null, 0, 1])
    @IsOptional()
    pStore?: number;

    @ApiProperty()
    @IsIn([undefined, null, 0, 1])
    @IsOptional()
    pSupplier?: number;

    @ApiProperty()
    @IsIn([undefined, null, 0, 1])
    @IsOptional()
    pTipology?: number;

    @ApiProperty()
    @IsIn([undefined, null, 0, 1])
    @IsOptional()
    pUnitMeasure?: number;

    @ApiProperty()
    @IsIn([undefined, null, 0, 1])
    @IsOptional()
    pUser?: number;

    @ApiProperty()
    @IsIn([undefined, null, 0, 1])
    @IsOptional()
    pMedia?: number;

    @ApiProperty()
    @IsIn([undefined, null, 0, 1])
    @IsOptional()
    pAi?: number;

}

export class UserDtoLogIn {
    
    @ApiProperty(
        {
            description: "Nome utente",
            default: "admin"
        }
    )
    @IsString()
    username?: string;

    @ApiProperty(
        {
            description: "Password utente",
            default: "Admin2026!"
        }
    )
    @IsString()
    password?: string;

}