Export createChainableTypeChecker?
Is there any reason why this function isn't exported (other than the ReactPropTypesSecret bit)? Every library or project that implements custom type checkers needs to write their own copy of it.
fwiw, airbnb-prop-types doesn't; we use a different, more explicit/less metaprogrammy approach.
I'm envisioning writing stuff like ofAtLeastSize that checks array length, and withProps that checks that props exist on an element, so I could write something like:
static propTypes = {
children: PropTypes
.array
.ofAtLeastSize(1)
.arrayOf(withProps({ name: PropTypes.string.isRequired }))
.isRequired,
}
I'm aware I could write all of the above into one gross custom validator, but the idea of composable chainable validation calls to me with a very pretty voice.
Am I trying to get too clever with prop-types?
@Asday airbnb-prop-types already has withShape that allows for it, eg, withShape(PropTypes.array, { length: range(1, Infinity) }).