Giter Club home page Giter Club logo

class-mapper's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

class-mapper's Issues

Support for transformation of nullable fields

Is your feature request related to a problem? Please describe.
I am unable to use the PropertyType decorator for property which may be null or undefined.

Describe the solution you'd like
The solution might be as simple as adding the enabled option behaving exactly the same as it does in the MapFromSource decorator but independently of each other

Additional context
Simple example of the problem:

class Foo {
    @MapFromSource(obj => obj.anything)
    public something!: string;
}

class Bar {
    @PropertyType(Foo)
    @MapFromSource(obj => obj.maybeFoo)
    public foo!: Foo | null;
}

This one works as expected:

mapClasses({
    maybeFoo: {
        anything: 'whatever'
    }
}, Bar);

But this one:

mapClasses({
    maybeFoo: null
}, Bar);

Throws an error, however i would expect the result to be this:

{
    foo: null
}

Nested array property was not working mapper

Describe the bug

I tried to use this library for serialization responsed dto. so I wanted to transform typeorm entity to response dto class.

when target class was nested class, it has an array property. I tried to use PropertyType decorator . but I got an error.

May I know how? plz answer me . thanks

To Reproduce
Steps to reproduce the behavior:

  1. Go to '...'
  2. Click on '....'
  3. Scroll down to '....'
  4. See error

Expected behavior
A clear and concise description of what you expected to happen.

Screenshots
If applicable, add screenshots to help explain your problem.

스크린샷 2021-03-15 오후 5 05 48

Additional Information (please complete the following information):

  • OS: [macOS Catalina]
  • Browser [None]
  • Node.js Version [12.16.3]
  • Library Version [0.2.3]

Additional context
Add any other context about the problem here.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.