MichalLytek / class-transformer-validator

A simple plugin for class-transformer and class-validator which combines them in a nice and programmer-friendly API.
MIT License
200 stars 19 forks source link

class-transformer 0.2.2 breaks transformAndValidate #20

Closed eyexpo-isaac closed 4 years ago

eyexpo-isaac commented 5 years ago

It should relate to this issue in class-transformer after they released 0.2.2 yesterday

import { transformAndValidate } from 'class-transformer-validator';

class User {
  @IsEmail()
  identifier!: string;

  @IsString()
  password!: string;
}

const user: User = {
  identifier: 'johndoe@gmail.com',
  password: 'password123',
};

const userJson: string = JSON.stringify(user);

await transformAndValidate(User, userJson)
  .then(async (): Promise<void> => Promise.resolve())
  .catch(async (err: Error): Promise<never> => Promise.reject(err));

Throw error TypeError: Reflect.getMetadata is not a function

Which was working fine before(before they upgrade to 0.2.2)

By adding

import 'reflect-metadata';

at the top solved this issue.

NoNameProvided commented 5 years ago

This is probably an upstream issue in class-transformer, I have commented on your issue at typestack/class-transformer#255, please continue the conversation there.

MichalLytek commented 4 years ago

Closing for a housekeeping purposes 🔒