'Object validation - How to validate [key: number]: string
I'm trying to write validator for JSON
returned from Bugzilla API. When I'm fetching comments data, I'm getting something like this:
curl https://bugzilla.mozilla.org/rest/bug/comment/1
{
"comments": {
"1": {...}
},
"bugs": {}
}
The number "1" refers to comment id, so typescript definition would be something like this:
export interface Comment {
comments: {
[key: number]: CommentObject;
};
...
}
My question is, is there way how to validate property names of objects? I checks class-validator
and some others and to me it seems that all of those libraries are focusing only on validation of property values.
Thanks in advance for any suggestions.
Solution 1:[1]
I was able to resolve my issue with help of Dave from bugzilla-ts
Solution can be found at: Mossop/bugzilla-ts#41
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | jamacku |