Last active
July 30, 2019 14:40
-
-
Save michielmulders/3ae3aac6f0a1d8ad17ba16222fbc2cf9 to your computer and use it in GitHub Desktop.
InvoiceTransaction validate asset
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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