Allow destination to not have all src fields
rmohr opened this issue · 5 comments
In order to do mapping from internal objects to different external data transfer objects, it would be nice if we could say that "missing fields" on the destination are not an error.
Currently I get errors like
Field: 'Y', does not exists
For illustration:
type DomainObject struct {
Name string
Address string
Phone string
}
type LoginGreeterDTO struct {
Name string
}
model.Copy(&loginGreetingDTO, &domainObject )
@jeevatkm No, PR #11 is a bugfix. Without that the code panics. After you apply this fix, you will get the correct error notifications like above, that fields don't exist.
I did not start looking into this enhancement. It might be nice to supply allowed strategies (something like "strict" which requires all fields to have a match on the destination object and "weak" where this is not required).
This might be an interesting read regarding to mapping strategies: http://modelmapper.org/user-manual/configuration/#matching-strategies
Maybe we can work something out together.
Thanks for the reference. I will have a look.
Done!
I have chosen default as weak strategies. So matching field will be processed.