<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>Forem: Dan Muntean</title>
    <description>The latest articles on Forem by Dan Muntean (@danutalexandru).</description>
    <link>https://forem.com/danutalexandru</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F1441572%2F561799fe-d5c4-4d0f-a693-2731f7832ae6.jpeg</url>
      <title>Forem: Dan Muntean</title>
      <link>https://forem.com/danutalexandru</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://forem.com/feed/danutalexandru"/>
    <language>en</language>
    <item>
      <title>Getting an error when using @ValidateNested decorator in NestJs</title>
      <dc:creator>Dan Muntean</dc:creator>
      <pubDate>Mon, 22 Apr 2024 10:51:38 +0000</pubDate>
      <link>https://forem.com/danutalexandru/getting-an-error-when-using-validatenested-decorator-in-nestjs-gco</link>
      <guid>https://forem.com/danutalexandru/getting-an-error-when-using-validatenested-decorator-in-nestjs-gco</guid>
      <description>&lt;p&gt;Hi, I'm working on an backend application which is using NestJs framework. Recently I updated the libraries and the class-validator library from 0.14.0 to 0.14.1 and mongo library from 6.0.0 to 6.5.0.&lt;br&gt;
After this update I am getting this error when trying to validate an array of ObjectId. &lt;/p&gt;

&lt;p&gt;[Nest] 60017  - 04/22/2024, 1:07:48 PM   ERROR Error [ERR_INTERNAL_ASSERTION]: Error: BSONError: Cannot create Buffer from undefined&lt;br&gt;
    at Object.toLocalBufferType &lt;br&gt;
    at Object.toHex &lt;br&gt;
    at ObjectId.toHexString &lt;br&gt;
    at ObjectId.inspect &lt;br&gt;
    at ObjectId.[nodejs.util.inspect.custom] &lt;br&gt;
    at formatValue (node:internal/util/inspect:782:19)&lt;br&gt;
    at formatProperty (node:internal/util/inspect:1819:11)&lt;br&gt;
    at formatArray (node:internal/util/inspect:1645:17)&lt;br&gt;
    at formatRaw (node:internal/util/inspect:1027:14)&lt;br&gt;
    at formatValue (node:internal/util/inspect:817:10)&lt;br&gt;
This is caused by either a bug in Node.js or incorrect usage of Node.js internals.&lt;br&gt;
Please open an issue with this stack trace at &lt;a href="https://github.com/nodejs/node/issues"&gt;https://github.com/nodejs/node/issues&lt;/a&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;@ApiProperty({ type: [ObjectId], required: false })
  @Transform(Transformers.objectIdJSONTransformer, {
    toClassOnly: true,
  })
  @IsOptional()
  @IsArray()
  @ValidateNested({ each: true })
  @Type(() =&amp;gt; ObjectId)
  podsIds?: ObjectId[];
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Need to mention that the @ValidateNested decorator is working on other validations which are objects. Thank you!&lt;/p&gt;

</description>
      <category>nestjs</category>
      <category>node</category>
    </item>
  </channel>
</rss>
