{"action":"opened","issue":{"url":"https://api.github.com/repos/typestack/class-transformer/issues/146","repository_url":"https://api.github.com/repos/typestack/class-transformer","labels_url":"https://api.github.com/repos/typestack/class-transformer/issues/146/labels{/name}","comments_url":"https://api.github.com/repos/typestack/class-transformer/issues/146/comments","events_url":"https://api.github.com/repos/typestack/class-transformer/issues/146/events","html_url":"https://github.com/typestack/class-transformer/issues/146","id":318668120,"number":146,"title":"Exclude() isn't working for HTTP POST responses","user":{"login":"kodayashi","id":916855,"avatar_url":"https://avatars1.githubusercontent.com/u/916855?v=4","gravatar_id":"","url":"https://api.github.com/users/kodayashi","html_url":"https://github.com/kodayashi","followers_url":"https://api.github.com/users/kodayashi/followers","following_url":"https://api.github.com/users/kodayashi/following{/other_user}","gists_url":"https://api.github.com/users/kodayashi/gists{/gist_id}","starred_url":"https://api.github.com/users/kodayashi/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kodayashi/subscriptions","organizations_url":"https://api.github.com/users/kodayashi/orgs","repos_url":"https://api.github.com/users/kodayashi/repos","events_url":"https://api.github.com/users/kodayashi/events{/privacy}","received_events_url":"https://api.github.com/users/kodayashi/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2018-04-28T20:56:24Z","updated_at":"2018-04-28T20:56:24Z","closed_at":null,"author_association":"NONE","body":"I'm using class-transformer in a NestJS project with TypeORM. I have configured the classToPlain() method to run for every single API response in NestJS with what they call an \"Interceptor\":\r\n\r\n```typescript\r\n@Interceptor()\r\nexport class TransformInterceptor implements NestInterceptor {\r\n  intercept(dataOrRequest, context: ExecutionContext, stream$: Observable<any>): Observable<any> {\r\n    return stream$.map((data) => classToPlain(data));\r\n  }\r\n}\r\n```\r\n\r\nMy User entity looks like this:\r\n\r\n```typescript\r\nimport { Entity, PrimaryGeneratedColumn, Column } from 'typeorm';\r\nimport { Exclude } from 'class-transformer';\r\n\r\ntype Gender = 'm' | 'f';\r\n\r\n@Entity()\r\nexport class User {\r\n\r\n    @PrimaryGeneratedColumn()\r\n    id: number;\r\n\r\n    @Column({ unique: true })\r\n    email: string;\r\n\r\n    @Exclude()\r\n    @Column({ length: 100 })\r\n    password: string;\r\n\r\n    @Column({ nullable: true })\r\n    firstName: string|undefined;\r\n\r\n    @Column({ nullable: true })\r\n    lastName: string|undefined;\r\n\r\n    @Column({ type: 'date', nullable: true })\r\n    dob: Date|undefined;\r\n\r\n    @Column({ name: 'gender', type: 'enum', enum: ['m', 'f'], nullable: true })\r\n    gender: Gender|undefined;\r\n\r\n    @Column({ nullable: true })\r\n    phoneNumber: string|undefined;\r\n}\r\n```\r\n\r\nIt's working great except for when I *create* a new User. Calls to get all users or get one user results in the password being excluded. But for some reason when I create a new user with an http `POST`, the response includes my hashed password:\r\n\r\n```javascript\r\n{\r\n    \"email\": \"tester016@test.com\",\r\n    \"firstName\": null,\r\n    \"lastName\": null,\r\n    \"dob\": null,\r\n    \"gender\": null,\r\n    \"phoneNumber\": null,\r\n    \"id\": 20\r\n}\r\n```\r\n\r\nDoes `Exclude()` not work when creating new resources?"}}
{"actor":{"display_login":"kodayashi"}}