pageSize: function(props, propName, componentName, ...rest) { if (!props[propName]){ return null; } if (!props.onChangePageSize){ return new Error('You provided a `pageSize` prop without an `onChangePageSize` handler. This will make the page size constant. If you want to set the default page size, use the `defaultPageSize` prop.'); } return PropTypes.number(props, propName, componentName, ...rest); },
page: function(props, propName, componentName, ...rest) { if (!props[propName]){ return null; } if (!props.onChangePage){ return new Error('You provided a `page` prop without an `onChangePage` handler. This will disable paging. If you want to set the default initial page, use the `defaultPage` prop.'); } return PropTypes.number(props, propName, componentName, ...rest); },
const valueInRangePropType = (props, propName, componentName, ...rest) => { const error = PropTypes.number(props, propName, componentName, ...rest); if (error !== null) { return error; } const value = props[propName]; if (value < props.min || props.max < value) { return new Error(`${propName} should be within the range specified by min and max`); } };
const minMaxPropType = (props, propName, componentName, ...rest) => { const error = PropTypes.number(props, propName, componentName, ...rest); if (error !== null) { return error; } if (props.min >= props.max) { const errorMsg = (propName === 'min') ? 'min should be less than max' : 'max should be greater than min'; return new Error(errorMsg); } };