Amount
isPositive
1.0.0- Dependencies:
- ∟Direct: 0
- ∟Peer: 0
- Source code ↗
- Check on NPM ↗
Hidden
Overview
Section titled “Overview”Checks if an amount is positive (greater than zero) by comparing the internal cents value.
amount.isPositive();Features
Section titled “Features”- Returns a boolean value indicating if the amount is positive
- Compares against the internal cents representation for precision
- Works with any currency
- Simple and intuitive API
- No side effects - read-only operation
- Comprehensive testing
Arguments
Section titled “Arguments”| Arg | Type | Default Value | Required |
| No arguments required | |||
From an Amount instance, use the isPositive() method to check if the amount is greater than zero.
import { amount } from '@inpulse-ui/utils';
const positiveAmount = amount(100, 'USD');const result = positiveAmount.isPositive();
console.log(result); // trueIt returns false for zero and negative amounts:
const zeroAmount = amount(0, 'EUR');const negativeAmount = amount(-50, 'GBP');
console.log(zeroAmount.isPositive()); // falseconsole.log(negativeAmount.isPositive()); // falseWorks with decimal values:
const smallPositive = amount(0.01, 'USD');const smallNegative = amount(-0.01, 'USD');
console.log(smallPositive.isPositive()); // trueconsole.log(smallNegative.isPositive()); // falseUseful for conditional logic:
const balance = amount(150.75, 'USD');
if (balance.isPositive()) { console.log('Account has a positive balance');} else { console.log('Account balance is zero or negative');}// Output: "Account has a positive balance"Validation for payment processing:
const paymentAmount = amount(25.00, 'USD');
if (paymentAmount.isPositive()) { console.log('Valid payment amount'); // Process payment} else { console.log('Invalid payment amount - must be positive');}// Output: "Valid payment amount"Built with by Jo Santana in Brazil.
© 2026 Inpulse. All rights reserved.