I call two endpoints that respond with inconsistent JSON structure.
In the 1st, JSON returned looks like this:
{
payinData: [{...}, {...}, ...],
amount: 3000
}
And in the 2nd:
{
payInData: [{...}, {...}, ...],
amount: 34500
}
The problem lies in the casing of object keys, i.e payinData in 1st is different from payInData in 2nd.
I want to use the same react component for data coming from these endpoints. I can handle this inconsistency in my code logic but don't know how to do the same in props validation with prop-types.
I have tried to do this:
MyComponent.propTypes = {
dataPayload: Proptypes.shape({
[Proptypes.oneOf(["payInData", "payinData"])]: Proptypes.arrayOf(Proptypes.shape({})),
amount: Proptypes.number
}),
}
But I get linting errors:
I think our priority here should be:
Have you considered the first 2 options?