ValidateNested without decorator is not working
See original GitHub issueLet’s say we have the following validation schema:
// this will not work
export const taskValidationSchema: ValidationSchema = {
name: 'TaskValidationSchema',
properties: {
'title': [
{
type: 'minLength',
constraints: [3],
groups: ['admin'],
}
],
'files': [
{
type: 'nestedValidation',
each: true,
groups: ['admin'],
}
]
}
};
Validator is not aware of which validation schema to use for the nested property.
Here is my solution:
export const taskValidationSchema: ValidationSchema = {
name: 'TaskValidationSchema',
properties: {
'title': [
{
type: 'minLength',
constraints: [3],
groups: ['admin'],
}
],
'files': [
{
type: 'nestedValidation',
options: {'validationSchema': 'TaskFileValidationSchema'},
each: true,
groups: ['admin'],
}
]
}
};
Would you accept PR?
Issue Analytics
- State:
- Created 5 years ago
- Reactions:6
- Comments:7 (3 by maintainers)
Top Results From Across the Web
Class-validator ignores ValidateNested objects - Stack Overflow
As the documentation says, the validated property must be a Class instance so the validation decorator will work. So, the solution for this ......
Read more >typestack/class-validator - Gitter
I'm trying to use class validator for validatin my inputtype in type-graphql but the @matches decorator, is not working, All other decorators with...
Read more >Validating nested objects with class-validator in NestJS
Today I have for you a quick and short article. Maybe it will help someone. I'm using class-validator for request validation in NestJS ......
Read more >class-validator - npm.io
This will strip all properties that don't have any decorators. If no other decorator is suitable for your property, you can use @Allow...
Read more >typestack/class-validator - CD2H gitForager
rt {ValidateNested} from "class-validator"; rt class Post ... If no other decorator is suitable for your property, you can use @Allow decorator:
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

@NoNameProvided any news on this?
@rlataguerra please open a different issue for your issue explaining the details and providing a small example.