question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Expose using groups

See original GitHub issue

Hi,

I’ve got an entity User like this :

@Entity()
export class User {
  @PrimaryGeneratedColumn()
  id: number;

  @Column()
  username: string;

  @IsOptional({ groups: [UPDATE] })
  @IsNotEmpty({ groups: [CREATE] })
  @IsEmail({}, { always: true })
  @Validate(PropertyNotExists, { always: true })
  @Expose({ groups: [Roles.ADMIN, Roles.OWNER], toPlainOnly: true })
  @Transform(val => val.toLocaleLowerCase(), { toClassOnly: true })
  @Column({ unique: true })
  email: string;
}

I want to expose email address only if the authenticated user is the owner or has the role “ADMIN”. It works for GET requests, but when i make a POST/PUT/PATCH request, the email property is excluded before saving the entity and i’ve got a bad request 400 with the error “email should not be empty”

Any idea how to resolve this issue ? Thanks

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
michaelyalicommented, Jan 6, 2020

@daviddlv you can set serialize options for each method to false (https://github.com/nestjsx/crud/wiki/Controllers#serialize) or even do it globally (https://github.com/nestjsx/crud/wiki/Controllers#global-options) and apply your own serialize interceptor

0reactions
herenicknamecommented, Dec 6, 2020

@zMotivat0r This doesn’t help.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Multiple Exposure Groups: Using a Reference Group - SPH
In this study there are no unexposed subjects, but we can classify them as having low, medium, and high exposure. To compute the...
Read more >
Expose app groups in the LDAP interface directory information ...
In the Admin Console, go to Directory > Directory Integrations. · Select an LDAP interface instance and click Edit. · In the Groups...
Read more >
Exposure Group - SAP Documentation
The exposure group object type (just like the position , job and task object types) can be used to indirectly assign agents with...
Read more >
What Happened To Exposé? | The Entire Group Was Fired ...
Miami nightclubs in the '80s were one of the hottest spots around to hear the familiar keyboard riffs and electro funk drum-machine patterns ......
Read more >
How Exposé Endured to Become One of the Most Successful ...
To this day, Exposé are huge in freestyle nostalgia circles, ... all of their hits, set out to create a group with three...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found