@basis-theory/basis-theory-reactor-formulas-sdk-js
Advanced tools
Comparing version 1.3.0 to 1.3.1
{ | ||
"name": "@basis-theory/basis-theory-reactor-formulas-sdk-js", | ||
"version": "1.3.0", | ||
"version": "1.3.1", | ||
"description": "Javascript SDK for building Basis Theory reactor formulas", | ||
@@ -47,4 +47,4 @@ "repository": "https://github.com/Basis-Theory/basistheory-reactor-formulas-sdk-js", | ||
"publishConfig": { | ||
"access": "restricted" | ||
"access": "public" | ||
} | ||
} |
# basistheory-reactor-formulas-sdk-js | ||
[![Version](https://img.shields.io/npm/v/@basis-theory/basis-theory-reactor-formulas-sdk-js.svg)](https://www.npmjs.org/package/@basis-theory/basis-theory-reactor-formulas-sdk-js) | ||
[![Verify](https://github.com/Basis-Theory/basistheory-reactor-formulas-sdk-js/actions/workflows/release.yml/badge.svg)](https://github.com/Basis-Theory/basistheory-reactor-formulas-sdk-js/actions/workflows/release.yml) | ||
Javascript SDK for building Basis Theory reactor formulas | ||
## Usage | ||
## Installation | ||
Install the package: | ||
Using [Node Package Manager](https://docs.npmjs.com/) | ||
```shell | ||
yarn add @basis-theory/basis-theory-reactor-formulas-sdk-js | ||
```sh | ||
npm install --save-dev @basis-theory/basis-theory-reactor-formulas-sdk-js | ||
``` | ||
Using [Yarn](https://classic.yarnpkg.com/en/docs/) | ||
```sh | ||
yarn add --dev @basis-theory/basis-theory-reactor-formulas-sdk-js | ||
``` | ||
## Development | ||
@@ -14,0 +23,0 @@ |
const sanitizeErrors = (errors) => { | ||
const sanitizedErrors = {}; | ||
const fallbackErrorMessage = | ||
'Something went wrong. Please try again. If the problem persists, please contact support@basistheory.com.'; | ||
if (Array.isArray(errors)) { | ||
@@ -10,8 +13,12 @@ sanitizedErrors['error'] = errors; | ||
sanitizedErrors[property] = errors[property].map((e) => | ||
e === 'object' ? JSON.stringify(e) : e.toString() | ||
typeof e === 'object' | ||
? JSON.stringify(e) | ||
: e?.toString() ?? fallbackErrorMessage | ||
); | ||
} else if (typeof errors[property] === 'object') { | ||
sanitizedErrors[property] = [JSON.stringify(errors[property])]; | ||
} else if (errors[property]) { | ||
sanitizedErrors[property] = [errors[property].toString()]; | ||
} else { | ||
sanitizedErrors[property] = [errors[property].toString()]; | ||
sanitizedErrors[property] = [fallbackErrorMessage]; | ||
} | ||
@@ -23,2 +30,4 @@ } | ||
sanitizedErrors['error'] = [errors.toString()]; | ||
} else { | ||
sanitizedErrors['error'] = [fallbackErrorMessage]; | ||
} | ||
@@ -25,0 +34,0 @@ |
18649
14
162
28