// the find
ljharb/prop-types-tools
Custom React PropType validators
A set of composable React PropType validators that fill gaps in the stock prop-types package: numeric ranges, unique arrays, mutually exclusive props, and constraints on children. It is for React teams that still run runtime prop validation and want stricter contracts than PropTypes.shape alone gives them.
- In production builds, each export is swapped for a no-op mock, so bundlers can drop the real implementations entirely. That is the correct behavior for a library whose checks never run in prod anyway.
- Validators compose. `and`, `or`, `sequenceOf`, `shape`, and `childrenOf` take other validators as arguments, so `uniqueArrayOf(number)` or `childrenOf(number.isRequired)` states the contract directly instead of hiding it in a custom function.
- The children validators (`childrenOfType`, `childrenSequenceOf`, `nChildren`, `childrenHavePropXorChildren`) cover cases the stock package cannot express. They sit on a shared `renderableChildren` helper, so they reason about what React actually renders rather than the raw children array.
- Each validator has its own test file and the project reports coverage to Codecov, so the per-function behavior is easy to check when you want to know exactly what a rule accepts.
- The whole library assumes runtime propTypes. React 19 stopped checking propTypes on function components, so on a modern React codebase much of this only helps if you still validate in development or in a legacy tree.
- The README says to use airbnb-js-shims 'or the equivalent' without listing which built-ins the validators depend on. Adopters who skip the shims have to read the source to find out what they are relying on.
- Documentation is a single long bullet list with signatures and one-line examples. The edge cases, such as the function form of `between`, the `stripHOCs` rules in `componentWithName`, and how `disallowedIf` treats null, get a sentence each, and that is where surprises will show up.
- The last push was 2025-12-30. For a small library that exists to track React's prop behavior, a stretch of no commits is worth checking against React's current release before you depend on it.