| 123456789101112131415161718192021222324252627282930313233 |
- import {InvalidArgumentError} from '@e22m4u/js-format';
- import {validateProjectionSchema} from './validate-projection-schema.js';
- /**
- * Validate projection schema definition.
- *
- * @param {object} schemaDef
- */
- export function validateProjectionSchemaDefinition(schemaDef) {
- if (!schemaDef || typeof schemaDef !== 'object' || Array.isArray(schemaDef)) {
- throw new InvalidArgumentError(
- 'Schema definition must be an Object, but %v was given.',
- schemaDef,
- );
- }
- if (!schemaDef.name || typeof schemaDef.name !== 'string') {
- throw new InvalidArgumentError(
- 'Definition option "name" must be a non-empty String, but %v was given.',
- schemaDef.name,
- );
- }
- if (
- !schemaDef.schema ||
- typeof schemaDef.schema !== 'object' ||
- Array.isArray(schemaDef.schema)
- ) {
- throw new InvalidArgumentError(
- 'Definition option "schema" must be an Object, but %v was given.',
- schemaDef.schema,
- );
- }
- validateProjectionSchema(schemaDef.schema);
- }
|