Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feature: ValidateNested Array is not Working #2482

Open
edutucci opened this issue May 27, 2024 · 0 comments
Open

feature: ValidateNested Array is not Working #2482

edutucci opened this issue May 27, 2024 · 0 comments
Labels
flag: needs discussion Issues which needs discussion before implementation. type: feature Issues related to new features.

Comments

@edutucci
Copy link

Description

The decorator IsArray() does not check if the value is array.
In my example I need check the arrays allergen and additives in class NutritionalInfoDto.

import {
  IsArray,
  IsBoolean,
  IsIn,
  IsNotEmpty,
  IsNumber,
  IsObject,
  IsOptional,
  IsString,
  Min,
  ValidateNested,
} from 'class-validator'

class NutritionalInfoDto {
  @IsArray({ message: 'availabilityId precisa ser um array' })
  @IsString({
    message: 'todos os valores de availabilityId precisam ser uma string!',
    each: true,
  })
  @IsOptional()
  allergen: string[];

  @IsArray({ message: 'availabilityId precisa ser um array' })
  @IsString({
    message: 'todos os valores de availabilityId precisam ser uma string!',
    each: true,
  })
  @IsOptional()
  additives: string[];
}

export class ProductDto {
  @IsObject({ each: true })
  @ValidateNested({
    each: true,
    message: 'wrong values',
  })
  @Type(() => NutritionalInfoDto)
  nutritionalInfo: NutritionalInfoDto;
}
@edutucci edutucci added flag: needs discussion Issues which needs discussion before implementation. type: feature Issues related to new features. labels May 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
flag: needs discussion Issues which needs discussion before implementation. type: feature Issues related to new features.
Development

No branches or pull requests

1 participant