Skip to content

Commit

Permalink
chore: add jsdoc
Browse files Browse the repository at this point in the history
  • Loading branch information
solaris007 committed Nov 28, 2023
1 parent 9422449 commit 92ca7f3
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions packages/spacecat-shared-dynamo/src/utils/guards.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,18 +12,36 @@

import { hasText, isObject } from '@adobe/spacecat-shared-utils';

/**
* Validates that the provided table name is a non-empty string.
*
* @param {string} tableName - The name of the table to validate.
* @throws {Error} If the table name is empty or not a string.
*/
const guardTableName = (tableName) => {
if (!hasText(tableName)) {
throw new Error('Table name is required.');
}
};

/**
* Validates that the provided key is an object and contains a partitionKey.
*
* @param {object} key - The key object to validate.
* @throws {Error} If the key is not an object or does not contain a partitionKey.
*/
const guardKey = (key) => {
if (!isObject(key) || !key.partitionKey) {
throw new Error('Key must be an object with a partitionKey.');
}
};

/**
* Validates that the provided parameters object contains the required query parameters.
*
* @param {object} params - The parameters object to validate.
* @throws {Error} If the parameters object is not an object or is missing required properties.
*/
const guardQueryParameters = (params) => {
if (!isObject(params)) {
throw new Error('Query parameters must be an object.');
Expand Down

0 comments on commit 92ca7f3

Please sign in to comment.