1 | import PropTypes from 'prop-types';
|
2 | import { and } from 'airbnb-prop-types';
|
3 |
|
4 | export default and([
|
5 | PropTypes.instanceOf(Set),
|
6 | function modifiers(props, propName, ...rest) {
|
7 | const { [propName]: propValue } = props;
|
8 | let firstError;
|
9 | [...propValue].some((v, i) => {
|
10 | const fakePropName = `${propName}: index ${i}`;
|
11 | firstError = PropTypes.string.isRequired(
|
12 | { [fakePropName]: v },
|
13 | fakePropName,
|
14 | ...rest,
|
15 | );
|
16 | return firstError != null;
|
17 | });
|
18 | return firstError == null ? null : firstError;
|
19 | },
|
20 | ], 'Modifiers (Set of Strings)');
|