Check whether metatype exists and whether it is one of the JavaScript primitive constructors (String, Number, Boolean, Array, Object). If it is, return the value unchanged — there are no class-validator decorators on primitives. This guard prevents validate() from running on raw strings, numbers, or booleans.
Without the guard, the pipe tries to run validate() on a plain number or string — meaningless results.
String, Number, Boolean, Array, Object are JavaScript constructor functions, not class-validator targets.
metatype is undefined when no TypeScript type is associated — e.g. untyped @Query() params.
This is exactly what NestJS ValidationPipe does internally — checking against the same primitives array.
The guard enables the pipe to be applied globally without breaking non-DTO parameters.