@ethersphere/swarm-cli
Version:
CLI tool for Bee
24 lines (23 loc) • 763 B
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.validateTokenAmount = validateTokenAmount;
function validateTokenAmount(value, context) {
if (context.options.unit === 'bzz') {
const amount = parseFloat(value);
if (isNaN(amount) || amount <= 0) {
return [`Invalid amount '${value}'. Amount must be a positive number.`];
}
}
else {
try {
const amount = BigInt(value);
if (amount <= BigInt(0)) {
return [`Invalid amount '${value}'. Amount must be a positive integer.`];
}
}
catch (e) {
return [`Invalid amount '${value}'. Amount must be a positive integer.`];
}
}
return [];
}