@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 +1 -0
- package/dist/index.js +4 -0
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
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