@paybyrd/devagent-test-js 1.0.0 → 2.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.ts CHANGED
@@ -1,6 +1,7 @@
1
1
  export interface PaymentRequest {
2
2
  amount: number;
3
3
  reference: string;
4
+ currency: string;
4
5
  }
5
6
  export interface ValidationResult {
6
7
  valid: boolean;
package/dist/index.js CHANGED
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.validatePayment = validatePayment;
4
+ const SUPPORTED_CURRENCIES = ["EUR", "USD", "GBP"];
4
5
  function validatePayment(request) {
5
6
  const errors = [];
6
7
  if (!(request.amount > 0)) {
@@ -12,5 +13,8 @@ function validatePayment(request) {
12
13
  else if (request.reference.length > 50) {
13
14
  errors.push("reference must be at most 50 characters");
14
15
  }
16
+ if (!SUPPORTED_CURRENCIES.includes(request.currency)) {
17
+ errors.push(`currency must be one of ${SUPPORTED_CURRENCIES.join(", ")}`);
18
+ }
15
19
  return { valid: errors.length === 0, errors };
16
20
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@paybyrd/devagent-test-js",
3
- "version": "1.0.0",
3
+ "version": "2.0.0",
4
4
  "description": "Test package for the Paybyrd dev agent sandbox. Not for use: it has no real functionality.",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",