-
Notifications
You must be signed in to change notification settings - Fork 40
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
[CLASS_TRANSFORMERS] Extends class-transform package with EnumFallback decorator #837
[CLASS_TRANSFORMERS] Extends class-transform package with EnumFallback decorator #837
Conversation
7e342a2
to
aa9bc43
Compare
} | ||
|
||
if (!Object.values(type).includes(value)) { | ||
return fallback(value); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If there is error in the fallback function, you think we should throw error or return a specific value?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think so 🤔 Unlike the logging feature, this decorator may have a real impact on the application behaviour. In my opinion, it is more like the function you pass to Array.map
for instance. It means that if the given function fails, it is not the responsibility to the library to handle it.
What do you think?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay, so let the client handle it himself.
expect(user.role).toEqual('WRITER'); | ||
}); | ||
|
||
it('should return the fallback value for each invalid element if the property is an array', async () => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you please add a test when the fallback function is more than just returning a value? e.g. verifying a logging as we discussed
Description
Create class-transformers package with new decorator
EnumFallback
. This decorator can be used as follows:Finishes implementation started in #836
Motivation and Context
Fix #834
Types of changes