MCPcopy Create free account
hub / github.com/codex-team/editor.js / validateIndex

Method validateIndex

src/components/modules/api/blocks.ts:415–427  ·  view source on GitHub ↗

* Validated block index and throws an error if it's invalid * * @param index - index to validate

(index: unknown)

Source from the content-addressed store, hash-verified

413 * @param index - index to validate
414 */
415 private validateIndex(index: unknown): void {
416 if (typeof index !== 'number') {
417 throw new Error('Index should be a number');
418 }
419
420 if (index < 0) {
421 throw new Error(`Index should be greater than or equal to 0`);
422 }
423
424 if (index === null) {
425 throw new Error(`Index should be greater than or equal to 0`);
426 }
427 }
428}

Callers 1

BlocksAPIClass · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected