Skip to content

Instantly share code, notes, and snippets.

@michielmulders
Last active July 30, 2019 14:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save michielmulders/3ae3aac6f0a1d8ad17ba16222fbc2cf9 to your computer and use it in GitHub Desktop.
Save michielmulders/3ae3aac6f0a1d8ad17ba16222fbc2cf9 to your computer and use it in GitHub Desktop.
InvoiceTransaction validate asset
validateAsset() {
const errors = [];
if (!this.asset.client || typeof this.asset.client !== 'string') {
errors.push(
new TransactionError(
'Invalid "asset.client" defined on transaction',
this.id,
'.asset.client',
this.asset.client,
'A string value',
)
);
}
if (!this.asset.requestedAmount || typeof this.asset.requestedAmount !== 'string') {
errors.push(
new TransactionError(
'Invalid "asset.requestedAmount" defined on transaction',
this.id,
'.asset.requestedAmount',
this.asset.requestedAmount,
'A string value',
)
);
}
if (!this.asset.description || typeof this.asset.description !== 'string') {
errors.push(
new TransactionError(
'Invalid "asset.description" defined on transaction',
this.id,
'.asset.description',
this.asset.description,
'A string value',
)
);
}
return errors;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment