I am trying to do propTypes validation for of the array prop within my component. My propTypes validation looks something like this
Foo.propTypes = {
columns: PropTypes.arrayOf(
PropTypes.shape({
identifier: PropTypes.string,
displayName: PropTypes.string,
type: PropTypes.string,
align: PropTypes.oneOf(['right', 'left', 'center']),
sort: PropTypes.bool
})
)
}
Now I want to extend this validation with custom validation, by validating that only one value within columns array for sort property should be true
One option I have is to write the custom validation for whole columns array which would do PropTypes.arrayOf and PropTypes.shape validations and then do sort validation and throw error or null
But I don't want to do rework and want to utilize the inbuilt React.PropTypes to do all the validation and then add my custom validation