Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: plainToInstance is not working correcly #1744

Open
ingrocha opened this issue Aug 19, 2024 · 0 comments
Open

fix: plainToInstance is not working correcly #1744

ingrocha opened this issue Aug 19, 2024 · 0 comments
Labels
status: needs triage Issues which needs to be reproduced to be verified report. type: fix Issues describing a broken feature.

Comments

@ingrocha
Copy link

Description

Every time I attempt to convert req.body using plainToInstance, it adds a field id:"".

Minimal code-snippet showcasing the problem

export class Note {
	@Exclude()
	id = '';

	@Expose()
	title = '';

	@Expose()
	content = '';

	author = '';

	@Expose()
	sharedUsers: SharedUsers[] = [];

	createdAt?: Date;
	updatedAt?: Date;
}

const noteInputDto = plainToInstance(Note, req.body, {
    excludeExtraneousValues: true
});

Expected behavior

{
    "title":"test",
    "content":"test",
    "sharedUsers":[]
}

Actual behavior

{
        "id": "",
        "title": "test",
        "content": "test",
        "sharedUsers": []
}
@ingrocha ingrocha added status: needs triage Issues which needs to be reproduced to be verified report. type: fix Issues describing a broken feature. labels Aug 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: needs triage Issues which needs to be reproduced to be verified report. type: fix Issues describing a broken feature.
Development

No branches or pull requests

1 participant