title: How to validate duplicates in nestjs dto?
body: <p>In the Nest js create dto I receive two properties name and age. I need to validate if user with name and age already exists should trough 400 error &quot;duplicate values&quot;.
  Like in table we have name: &quot;John&quot;, age: 20
  and we create user with the same value/combination &quot;John&quot; and 20, it should show error.
  I tried to use validation check NameExists but do not know how to take values for both, I only take for one.
  <a href="https://dev.to/avantar/custom-validation-with-database-in-nestjs-gao" rel="nofollow noreferrer">https://dev.to/avantar/custom-validation-with-database-in-nestjs-gao</a></p>
  <pre><code>@IsNotEmpty({
      message: 'Name is missing',
    })
    @MinLength(5, {
      message: 'Name is too short. Select name longer than 5 characters.',
    })
    @UserExists()
    name: string;
  
  @IsNotEmpty({
      message: 'Age is missing.',
    })
    @IsInt()
    @Transform(({ value }) =&gt; Number(value))
    age: number;
  
  </code></pre>