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.

question: omit values

See original GitHub issue

Hi, Im build a nestjs API and I’m using class-validator.

I’m having little issues, but to be honest, I dont have much experience with class-validator.

I have 2 api operations POST and PATCH. When admin creates a new bot, all attributes should be validated by api. When admin updates something, the data should be updated partially.

Below, you can see my class:

@Exclude()
export class BotDto {

    @IsString()
    @Length(2, 50)
    @Expose()
    readonly name: string;

    @IsString()
    @IsEmail()
    @Expose()
    readonly email: string;

    @IsString()
    @Matches(/^\d{17}$/)
    // @IsBotSteamIdAlreadyExist()
    @Expose()
    readonly steamid: string;

    @IsString()
    @Length(8, 32)
    @Expose()
    readonly steampass: string;

    @IsString()
    @IsBase64()
    @Expose()
    readonly sharedSecret: string;

    @IsString()
    @IsBase64()
    @Expose()
    readonly identitySecret: string;
}

I’m trying to use @IsOptional({groups: ['patch']}) but isn’t working.

How can I omit some validations?

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Reactions:1
  • Comments:18 (7 by maintainers)

github_iconTop GitHub Comments

9reactions
gvonhagelcommented, Mar 5, 2020

This is still a problem.

1reaction
rusconcommented, Feb 25, 2021

I think the best way is to set always: true by default or create a global validator configuration where you can change the default behavior for this flag

Read more comments on GitHub >

github_iconTop Results From Across the Web

Remove unnecessary values from an Object in R Programming
omit () Function. na. omit() function in R Language is used to omit all unnecessary cases from data frame, matrix or vector.
Read more >
3 Example Codes for na.omit (Data Frame, Vector & by Column)
The na.omit R function removes all incomplete cases of a data object (typically of a data frame, matrix or vector). The syntax above...
Read more >
Omit values when fitting (lmfit nan_policy) - Stack Overflow
Now say for some arbitrary reason my signal is cutoff. Some part of my gaussian shaped signal is missing (some saturation effect). Fitting...
Read more >
How to test if a value is `omit`? - ansible - Server Fault
In the YAML file omit is just a plain string. To pass the special variable it has to be enclosed in the templating...
Read more >
Solved: Excluding a value in a list - Esri Community
I have two survey questions that reference the same list_name values . I wanted to know if it was possible to exclude the...
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