@trayio/connector-utils
Advanced tools
Comparing version 0.1.0 to 0.1.1
const deepMapKeys = require('./deepMapKeys'); | ||
const removeEmptyObjects = require('./removeEmptyObjects'); | ||
const lookup = require('./lookup'); | ||
const validatePaginationRange = require('./validatePaginationRange'); | ||
// const xmlFormatter = require('./xmlFormatter'); | ||
@@ -65,2 +66,3 @@ const { mustachedDDL, DDL } = require('./ddl'); | ||
DDL, | ||
validatePaginationRange, | ||
// Commenting for initial release pending functionality to add paths to treatAsArray | ||
@@ -67,0 +69,0 @@ // xml: { |
@@ -6,2 +6,3 @@ const ERROR_MESSAGES = { | ||
LOOKUP: 'The lookup operation encountered an issue.', | ||
PAGINATION: 'The validatePagination operation encountered an issue.', | ||
}; | ||
@@ -47,2 +48,8 @@ | ||
class PaginationError extends GenericInternalError { | ||
constructor(message = ERROR_MESSAGES.PAGINATION, ...errorArgs) { | ||
super(message, ...errorArgs); | ||
} | ||
} | ||
module.exports = { | ||
@@ -53,2 +60,3 @@ XMLError, | ||
LookupError, | ||
PaginationError, | ||
}; |
{ | ||
"name": "@trayio/connector-utils", | ||
"version": "0.1.0", | ||
"version": "0.1.1", | ||
"description": "Common utility functions used in connectors.", | ||
@@ -5,0 +5,0 @@ "main": "lib/index.js", |
@@ -101,2 +101,5 @@ # Connector-utils | ||
</dd> | ||
<dt><a href="#validatePaginationRange">validatePaginationRange(value, validation)</a></dt> | ||
<dd><p>Helper for validating user pagination input for a given range.</p> | ||
</dd> | ||
</dl> | ||
@@ -332,1 +335,26 @@ | ||
| collection | <code>Object</code> | The collection from which to remove empty objects. | | ||
<a name="validatePaginationRange"></a> | ||
## validatePaginationRange(value, validation) | ||
Helper for validating user pagination input for a given range. | ||
**Kind**: global function | ||
| Param | Type | Description | | ||
| --- | --- | --- | | ||
| value | <code>Integer</code> \| <code>String</code> | The value specified by user input. | | ||
| validation | <code>Object</code> | Values relating specifically to the validation requirements. | | ||
| validation.minRange | <code>Integer</code> \| <code>String</code> | The minimum range specified by the API. | | ||
| validation.maxRange | <code>Integer</code> \| <code>String</code> | The maximum range specified by the API. | | ||
| validation.inputName | <code>String</code> | The name of the input the range is associated with. | | ||
**Example** | ||
```js | ||
validatePaginationRange(50, { minRange: 1, maxRange: 100, inputName: 'page size' }) | ||
// no error thrown as pagination is within range | ||
validatePaginationRange(101, { minRange: 1, maxRange: 100, inputName: 'page size' }) | ||
// will throw a UserInputError as the pageSize is outside the range | ||
// Error message returned: 'The page size must be between 1 - 100.' | ||
``` |
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
33548
11
562
358