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.

auto validtion not working

See original GitHub issue
@JsonController()
class UserController {
    @Post('/login')
    login(@Body({validate: true}) user: User) {
        console.log('this is a valid body');
        return 'success!!!';
    }
}

class User {
    @IsEmail()
    email: string;

    @MinLength(6)
    password: string;
}

createExpressServer({
    controllers: [UserController]
}).listen(3000);

when ever I send the request it reply console.log(‘this is a valid body’); although this my config

useExpressServer(app, {
  cors: true,
  validation: true,
  classTransformer: true,
  routePrefix: '/api/v1',

  controllers: [UserController],
});

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Reactions:2
  • Comments:7

github_iconTop GitHub Comments

1reaction
golden-protocolcommented, Apr 25, 2021

@bratanon ah yes this problem. I have a simple patch that should solve the problem. not throughly tested yet. I honestly haven’t had time to create a PR. but the fix should be pretty simple.

@JsonController()
class UserController {
  @Post('/login')
  login(@Body({ validate: true }) user: User) {
    if (!(user instanceof User)) {
      //do something to show an error
    }
    console.log('this is a valid body');
    return 'success!!!';
  }
}

0reactions
github-actions[bot]commented, Jul 12, 2021

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Validation on auto-populated field in a form in not working
For the validation I check if each input value is required , has the required max length and min length . Once complete...
Read more >
Automatic Revalidation - US Visas - travel.gov
Automatic revalidation is not the same as applying for a new visa. If you apply for a new nonimmigrant visa you cannot take...
Read more >
automatic redirection for custom validation not working
Getting methodnotallowed exception for custom validation AppServiceProvider.php Validator::extend('check_sold_amount', function($attribute, $value, ...
Read more >
Auto-configured validation not working · Issue #13897 - GitHub
I'm expecting that validation will work in project made with next steps: Go to http://start.spring.io Select Gradle Project, Kotlin, ...
Read more >
More on data validation - Microsoft Support
Tips for working with data validation · Users are not copying or filling data · Manual recalculation is turned off · Formulas are...
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