New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: ValidateNested support multi-dimensional arrays #539
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good for me. Could you please add some note to docs about multidimensional arrays?
mySubSubClasses: MySubClass[][]; | ||
|
||
@ValidateNested() | ||
mySubSubSubClasses: MySubClass[][][]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
does it work with tuples too? myTupleClasses: [MyClass1, MyClass2];
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This PR is about multidimensional arrays. myTupleClasses: [MyClass1, MyClass2];
is basically simple array (we already support simple arrays). But we validate only items of array. So for example this will pass:
class Tuple1 {
@IsNumber()
num: number;
}
class Tuple2 {
@IsString()
name: string;
}
class Test {
@ValidateNested()
tuples: [Tuple1, Tuple2];
}
const t = new Test();
t.tuples = [new Tuple1(), new Tuple1() as any];
t.tuples[0].num = 2 as any;
(t.tuples[1] as any).num = 2 as any;
console.log(validateSync(t));
4a50e67
to
89d7c82
Compare
I've added a very simple example about multi dimensional array. |
This is not full support of multi-dimensional arrays but at least @ValidateNested works now. |
This pull request has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
@NoNameProvided This PR aims to fix #538