From d890b8192467a28a2ec676070a393794874a7706 Mon Sep 17 00:00:00 2001 From: Denis Angell Date: Wed, 15 Feb 2023 13:23:56 -0500 Subject: [PATCH] update validation error response --- packages/xrpl/src/models/transactions/escrowCreate.ts | 6 +++--- packages/xrpl/test/models/escrowCreate.test.ts | 4 ++-- packages/xrpl/test/models/paymentChannelClaim.test.ts | 8 ++++---- packages/xrpl/test/models/paymentChannelCreate.test.ts | 4 ++-- packages/xrpl/test/models/paymentChannelFund.test.ts | 4 ++-- 5 files changed, 13 insertions(+), 13 deletions(-) diff --git a/packages/xrpl/src/models/transactions/escrowCreate.ts b/packages/xrpl/src/models/transactions/escrowCreate.ts index 90801c75..8c0a327f 100644 --- a/packages/xrpl/src/models/transactions/escrowCreate.ts +++ b/packages/xrpl/src/models/transactions/escrowCreate.ts @@ -2,7 +2,7 @@ import { ValidationError } from '../../errors' import { Amount } from '../common' -import { BaseTransaction, validateBaseTransaction } from './common' +import { BaseTransaction, isAmount, validateBaseTransaction } from './common' /** * Sequester amount until the escrow process either finishes or is canceled. @@ -56,8 +56,8 @@ export function validateEscrowCreate(tx: Record): void { throw new ValidationError('EscrowCreate: missing field Amount') } - if (typeof tx.Amount !== 'string') { - throw new ValidationError('EscrowCreate: Amount must be a string') + if (typeof tx.Amount !== 'string' && !isAmount(tx.Amount)) { + throw new ValidationError('EscrowCreate: Amount must be an Amount') } if (tx.Destination === undefined) { diff --git a/packages/xrpl/test/models/escrowCreate.test.ts b/packages/xrpl/test/models/escrowCreate.test.ts index 20ccf40f..1ec09612 100644 --- a/packages/xrpl/test/models/escrowCreate.test.ts +++ b/packages/xrpl/test/models/escrowCreate.test.ts @@ -82,12 +82,12 @@ describe('EscrowCreate', function () { assert.throws( () => validateEscrowCreate(escrow), ValidationError, - 'EscrowCreate: Amount must be a string', + 'EscrowCreate: Amount must be an Amount', ) assert.throws( () => validate(escrow), ValidationError, - 'EscrowCreate: Amount must be a string', + 'EscrowCreate: Amount must be an Amount', ) }) diff --git a/packages/xrpl/test/models/paymentChannelClaim.test.ts b/packages/xrpl/test/models/paymentChannelClaim.test.ts index 82de2777..f1958860 100644 --- a/packages/xrpl/test/models/paymentChannelClaim.test.ts +++ b/packages/xrpl/test/models/paymentChannelClaim.test.ts @@ -77,12 +77,12 @@ describe('PaymentChannelClaim', function () { assert.throws( () => validatePaymentChannelClaim(channel), ValidationError, - 'PaymentChannelClaim: invalid Balance', + 'PaymentChannelClaim: Balance must be an Amount', ) assert.throws( () => validate(channel), ValidationError, - 'PaymentChannelClaim: invalid Balance', + 'PaymentChannelClaim: Balance must be an Amount', ) }) @@ -92,12 +92,12 @@ describe('PaymentChannelClaim', function () { assert.throws( () => validatePaymentChannelClaim(channel), ValidationError, - 'PaymentChannelClaim: invalid Amount', + 'PaymentChannelClaim: Amount must be an Amount', ) assert.throws( () => validate(channel), ValidationError, - 'PaymentChannelClaim: invalid Amount', + 'PaymentChannelClaim: Amount must be an Amount', ) }) diff --git a/packages/xrpl/test/models/paymentChannelCreate.test.ts b/packages/xrpl/test/models/paymentChannelCreate.test.ts index 52915bb8..8bf30ef3 100644 --- a/packages/xrpl/test/models/paymentChannelCreate.test.ts +++ b/packages/xrpl/test/models/paymentChannelCreate.test.ts @@ -106,12 +106,12 @@ describe('PaymentChannelCreate', function () { assert.throws( () => validatePaymentChannelCreate(channel), ValidationError, - 'PaymentChannelCreate: invalid Amount', + 'PaymentChannelCreate: Amount must be an Amount', ) assert.throws( () => validate(channel), ValidationError, - 'PaymentChannelCreate: invalid Amount', + 'PaymentChannelCreate: Amount must be an Amount', ) }) diff --git a/packages/xrpl/test/models/paymentChannelFund.test.ts b/packages/xrpl/test/models/paymentChannelFund.test.ts index a8be2698..fd18f80f 100644 --- a/packages/xrpl/test/models/paymentChannelFund.test.ts +++ b/packages/xrpl/test/models/paymentChannelFund.test.ts @@ -70,12 +70,12 @@ describe('PaymentChannelFund', function () { assert.throws( () => validatePaymentChannelFund(channel), ValidationError, - 'PaymentChannelFund: invalid Amount', + 'PaymentChannelFund: Amount must be an Amount', ) assert.throws( () => validate(channel), ValidationError, - 'PaymentChannelFund: invalid Amount', + 'PaymentChannelFund: Amount must be an Amount', ) })