update validation error response

This commit is contained in:
Denis Angell
2023-02-15 13:23:56 -05:00
parent 81f09ba043
commit d890b81924
5 changed files with 13 additions and 13 deletions

View File

@@ -2,7 +2,7 @@
import { ValidationError } from '../../errors' import { ValidationError } from '../../errors'
import { Amount } from '../common' 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. * Sequester amount until the escrow process either finishes or is canceled.
@@ -56,8 +56,8 @@ export function validateEscrowCreate(tx: Record<string, unknown>): void {
throw new ValidationError('EscrowCreate: missing field Amount') throw new ValidationError('EscrowCreate: missing field Amount')
} }
if (typeof tx.Amount !== 'string') { if (typeof tx.Amount !== 'string' && !isAmount(tx.Amount)) {
throw new ValidationError('EscrowCreate: Amount must be a string') throw new ValidationError('EscrowCreate: Amount must be an Amount')
} }
if (tx.Destination === undefined) { if (tx.Destination === undefined) {

View File

@@ -82,12 +82,12 @@ describe('EscrowCreate', function () {
assert.throws( assert.throws(
() => validateEscrowCreate(escrow), () => validateEscrowCreate(escrow),
ValidationError, ValidationError,
'EscrowCreate: Amount must be a string', 'EscrowCreate: Amount must be an Amount',
) )
assert.throws( assert.throws(
() => validate(escrow), () => validate(escrow),
ValidationError, ValidationError,
'EscrowCreate: Amount must be a string', 'EscrowCreate: Amount must be an Amount',
) )
}) })

View File

@@ -77,12 +77,12 @@ describe('PaymentChannelClaim', function () {
assert.throws( assert.throws(
() => validatePaymentChannelClaim(channel), () => validatePaymentChannelClaim(channel),
ValidationError, ValidationError,
'PaymentChannelClaim: invalid Balance', 'PaymentChannelClaim: Balance must be an Amount',
) )
assert.throws( assert.throws(
() => validate(channel), () => validate(channel),
ValidationError, ValidationError,
'PaymentChannelClaim: invalid Balance', 'PaymentChannelClaim: Balance must be an Amount',
) )
}) })
@@ -92,12 +92,12 @@ describe('PaymentChannelClaim', function () {
assert.throws( assert.throws(
() => validatePaymentChannelClaim(channel), () => validatePaymentChannelClaim(channel),
ValidationError, ValidationError,
'PaymentChannelClaim: invalid Amount', 'PaymentChannelClaim: Amount must be an Amount',
) )
assert.throws( assert.throws(
() => validate(channel), () => validate(channel),
ValidationError, ValidationError,
'PaymentChannelClaim: invalid Amount', 'PaymentChannelClaim: Amount must be an Amount',
) )
}) })

View File

@@ -106,12 +106,12 @@ describe('PaymentChannelCreate', function () {
assert.throws( assert.throws(
() => validatePaymentChannelCreate(channel), () => validatePaymentChannelCreate(channel),
ValidationError, ValidationError,
'PaymentChannelCreate: invalid Amount', 'PaymentChannelCreate: Amount must be an Amount',
) )
assert.throws( assert.throws(
() => validate(channel), () => validate(channel),
ValidationError, ValidationError,
'PaymentChannelCreate: invalid Amount', 'PaymentChannelCreate: Amount must be an Amount',
) )
}) })

View File

@@ -70,12 +70,12 @@ describe('PaymentChannelFund', function () {
assert.throws( assert.throws(
() => validatePaymentChannelFund(channel), () => validatePaymentChannelFund(channel),
ValidationError, ValidationError,
'PaymentChannelFund: invalid Amount', 'PaymentChannelFund: Amount must be an Amount',
) )
assert.throws( assert.throws(
() => validate(channel), () => validate(channel),
ValidationError, ValidationError,
'PaymentChannelFund: invalid Amount', 'PaymentChannelFund: Amount must be an Amount',
) )
}) })