-
Notifications
You must be signed in to change notification settings - Fork 4
Open
Labels
Milestone
Description
Airbnb created a number of custom prop types (https://github.com/airbnb/prop-types), and we should allow for the generation of these (and any other) custom types. For instance, using their empty validator:
const customGenerators = { empty: () => null }
generateProps.init({ generators: customGenerators })
// Note: init doesn't currently take any options
import { empty } from 'airbnb-prop-types'
Component.propTypes = { alwaysEmpty: empty.isRequired }
generateProps(Component)
// => Current: {}
// => Proposed: { alwaysEmpty: null }A real world example that I'd like right now:
generateProps.init({ generators: { dateString: () => moment().format() } })
import { dateString } from 'lib/custom-prop-types'
Component.propTypes = { insertedAt: dateString.isRequired }
generateProps(Component)
// => Current: {}
// => Proposed: { insertedAt: '2019-06-12T17:23:27-04:00' }markalfred