Giter Site home page Giter Site logo

Comments (5)

NarHakobyan avatar NarHakobyan commented on July 23, 2024

Hi @chenguzhen87, I have chacked and it's working

from awesome-nest-boilerplate.

osmanraifgunes avatar osmanraifgunes commented on July 23, 2024
@Post('update')
@Roles(RoleType.ADMIN)
@HttpCode(HttpStatus.OK)
@ApiResponse({
        status: HttpStatus.OK,
        description: 'Edit user',
        type: UserDto,
    })

updateUser(@Body() userDto: UserDto): Promise<UserEntity> {
        return this._userService.updateUser(userDto);
    }

same here.

Error message :

TypeError: Cannot read property 'id' of undefined
at new AbstractDto (/home/raif/code/CoinTradeMimic/server/src/common/dto/AbstractDto.ts:11:26)
at new UserDto (/home/raif/code/CoinTradeMimic/server/src/modules/user/dto/UserDto.ts:45:9)

from awesome-nest-boilerplate.

NarHakobyan avatar NarHakobyan commented on July 23, 2024

@osmanraifgunes @chenguzhen87 body always needs to be validated, without that it will not convert to class, use class-validator decorators to do that.

for example

class UserDto {
@IsString()
readonly username: string;
@IsString()
readonly password: string;
}

from awesome-nest-boilerplate.

osmanraifgunes avatar osmanraifgunes commented on July 23, 2024

I need some nullable areas and @IsString() is forcing me to not-null values.

from awesome-nest-boilerplate.

NarHakobyan avatar NarHakobyan commented on July 23, 2024

@osmanraifgunes use @IsOptional() decorator.

you can find more here https://github.com/typestack/class-validator

from awesome-nest-boilerplate.

Related Issues (20)

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.