title: What is a metatype in nestjs?
body: <p>Reading the official nestjs doc, I've come across the following implementation of <code>ValidationPipe</code>:</p>
  
  <pre><code>import { PipeTransform, Injectable, ArgumentMetadata, BadRequestException } from '@nestjs/common';
  import { validate } from 'class-validator';
  import { plainToClass } from 'class-transformer';
  
  @Injectable()
  export class ValidationPipe implements PipeTransform&lt;any&gt; {
    async transform(value: any, { metatype }: ArgumentMetadata) {
      if (!metatype || !this.toValidate(metatype)) {
        return value;
      }
      const object = plainToClass(metatype, value);
      const errors = await validate(object);
      if (errors.length &gt; 0) {
        throw new BadRequestException('Validation failed');
      }
      return value;
    }
  
    private toValidate(metatype: Function): boolean {
      const types: Function[] = [String, Boolean, Number, Array, Object];
      return !types.includes(metatype);
    }
  }
  </code></pre>
  
  <p>I don't understand the logic put in the <code>transform</code> method. It would be great if someone would explain this piece line by line. I think the problem steams from the fact that I don't quite understand what <code>ArgumentMetadata</code> is and where it comes from.</p>