question: How to use @Param('id') in DTO class
i want to make isUnique with custom validator, it already works but in update case it doesn't works because i need the id of the entity that i update to exclude it from checking the field, or there is another example to implement isUnique in NestJS with typeOrm? thanks
Could you explain a little more clearly what you want to do, and perhaps write a little example?
Is it possible to implement what you need using ValidateIf?
import { customValidator } from './my-custom-validator.js';
import * as v from 'class-validator';
export class MyClass {
@v.IsString()
@v.IsOptional()
id?: string;
// the validators on this field will only be checked if id is not undefined
// that is, if ValidateIf's callback function returns true
@v.ValidateIf((object: MyClass) => object.id !== undefined)
@v.Validate(customValidator)
myField: string
}
Sorry, I cannot understand your problem. Closing this as cannot reproduce.
If the issue still persists, you may open a new Q&A in the discussions tab and someone from the community may be able to help.
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.