@s-ui/react-molecule-pagination
Version:
`MoleculePagination` is a component that displays a range of pages with the current page highlighted and the proper buttons to navigate across the available pages in the entire range of total pages
22 lines (21 loc) • 739 B
JavaScript
import { getMessageErrorInRange, getMessageErrorNumber, getMessageErrorPositive } from './helpers.js';
var isValidPage = function isValidPage(props, propName, componentName) {
var page = props[propName];
var totalPages = props.totalPages;
if (page === undefined) return null;
if (typeof page !== 'number') return new Error(getMessageErrorNumber({
propName: propName,
componentName: componentName
}));
if (page <= 0) return new Error(getMessageErrorPositive({
propName: propName,
componentName: componentName
}));
if (page > totalPages) return new Error(getMessageErrorInRange({
propName: propName,
componentName: componentName
}));
// assume all ok
return null;
};
export default isValidPage;