react-dates
Version:
A responsive and accessible date range picker component built with React
21 lines (19 loc) • 590 B
JavaScript
import PropTypes from 'prop-types';
import { and } from 'airbnb-prop-types';
export default and([
PropTypes.instanceOf(Set),
function modifiers(props, propName, ...rest) {
const { [propName]: propValue } = props;
let firstError;
[...propValue].some((v, i) => {
const fakePropName = `${propName}: index ${i}`;
firstError = PropTypes.string.isRequired(
{ [fakePropName]: v },
fakePropName,
...rest,
);
return firstError != null;
});
return firstError == null ? null : firstError;
},
], 'Modifiers (Set of Strings)');