Open synaptiko opened 5 years ago
Loosely based on https://github.com/ciena-blueplanet/ember-prop-types/issues/116 We use iface in our project, it's really similar to shape, the difference is that only specified props are checked.
iface
shape
Here's an example:
propTypes: { dog: PropTypes.iface({ bark: PropTypes.function.isRequired, color: PropTypes.string }).isRequired },
Then you can pass:
dog: Ember.Object.extend({ bark() { console.log('woof woof') } }).create()
or
dog: Ember.Object.extend({ bark() { console.log('ruff ruff') }, color: 'black', breed: 'affenpinscher' }).create()
Both are accepted.
If there will be interest in this PR, I can go over the list below and update documentation and provide some tests.
This project uses semver, please check the scope of this PR:
Support for iface type which is checking provided props similar to shape type but the missing props are tolerated.
Overview
Summary
Loosely based on https://github.com/ciena-blueplanet/ember-prop-types/issues/116 We use
iface
in our project, it's really similar toshape
, the difference is that only specified props are checked.Here's an example:
Then you can pass:
or
Both are accepted.
Checklist
If there will be interest in this PR, I can go over the list below and update documentation and provide some tests.
Semver
This project uses semver, please check the scope of this PR:
CHANGELOG
Support for
iface
type which is checking provided props similar toshape
type but the missing props are tolerated.