class-validators for "child" or sub-inputs not firing. #1202
-
Hello! I have a The class-validators on the "child" I'm wondering if I'm missing something wrong, if this is just an unsupported feature, etc. Here is a simplified example: ResolverHere is the resolver. Obviously this is just an example, not the full file / class.. // .../resolvers/product-resolver.ts
@Service()
@Resolver(Product)
export class ProductResolver {
...
@Mutation(() => Product)
addProduct(
@Arg('newProductInput')
newProductInput: NewProductInput,
): Promise<Product> {
return this.productService.addNew({
data: newProductInput,
});
}
} Top level
|
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
Turns out I should have probably read the documentation closer. There is a section on validating nested objects, and as far as I can tell this is working as advertised. In case anybody finds this and the exact syntax isn't clear to you, this is what worked for me. In my top level
|
Beta Was this translation helpful? Give feedback.
Turns out I should have probably read the documentation closer.
There is a section on validating nested objects, and as far as I can tell this is working as advertised.
In case anybody finds this and the exact syntax isn't clear to you, this is what worked for me. In my top level
NewProductInput
example above, I added@ValidateNested({ each: true })
- in my case{ each: true }
was required because I have an array of PricingInput's. After adding this decorator, my PricingInput validator(s) fired as expected.