MCPcopy
hub / github.com/react-grid-layout/react-grid-layout / validateLayout

Function validateLayout

src/core/layout.ts:478–509  ·  view source on GitHub ↗
(
  layout: Layout,
  contextName: string = "Layout"
)

Source from the content-addressed store, hash-verified

476 * @throws Error if layout is invalid
477 */
478export function validateLayout(
479 layout: Layout,
480 contextName: string = "Layout"
481): void {
482 const requiredProps = ["x", "y", "w", "h"] as const;
483
484 if (!Array.isArray(layout)) {
485 throw new Error(`${contextName} must be an array!`);
486 }
487
488 for (let i = 0; i < layout.length; i++) {
489 const item = layout[i];
490 if (item === undefined) continue;
491
492 for (const key of requiredProps) {
493 const value = item[key];
494 if (typeof value !== "number" || Number.isNaN(value)) {
495 throw new Error(
496 `ReactGridLayout: ${contextName}[${i}].${key} must be a number! ` +
497 `Received: ${String(value)} (${typeof value})`
498 );
499 }
500 }
501
502 if (item.i !== undefined && typeof item.i !== "string") {
503 throw new Error(
504 `ReactGridLayout: ${contextName}[${i}].i must be a string! ` +
505 `Received: ${String(item.i)} (${typeof item.i})`
506 );
507 }
508 }
509}

Callers 2

utils-test.jsFile · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…