How to use the @liskhq/lisk-validator.validateTransferAmount function in @liskhq/lisk-validator

To help you get started, we’ve selected a few @liskhq/lisk-validator examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github LiskHQ / lisk-sdk-examples / scripts / create_sendable_transaction.js View on Github external
const validateInputs = ({
	amount,
	recipientId,
	recipientPublicKey,
	senderPublicKey,
	data,
}) => {
	if (!validateTransferAmount(amount)) {
		throw new Error('Amount must be a valid number in string format.');
	}

	if (!recipientId && !recipientPublicKey) {
		throw new Error(
			'Either recipientId or recipientPublicKey must be provided.',
		);
	}

	if (typeof recipientId !== 'undefined') {
		validateAddress(recipientId);
	}

	if (typeof senderPublicKey !== 'undefined') {
		validatePublicKey(senderPublicKey);
	}