facebook / prop-types

Runtime type checking for React props and similar objects
MIT License
4.48k stars 356 forks source link

Prop type for Date #325

Closed nomanurrehman closed 4 years ago

nomanurrehman commented 4 years ago

I just noticed there is no type checker for a date. It is also not possible to somehow have a regular expression that could be a fit in solution for this.

Was there any specific design decision that motivated this choice or pull requests are welcome for this?

Thank you for the great work.

ljharb commented 4 years ago

You can use PropTypes.instanceOf(Date), or for a more robust solution, use https://www.npmjs.com/package/is-date-object with predicate from https://www.npmjs.com/package/airbnb-prop-types.