Skip to content

Amount

isPositive

1.0.0

Checks if an amount is positive (greater than zero) by comparing the internal cents value.

amount.isPositive();
  • 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
ArgTypeDefault ValueRequired
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); // true

It returns false for zero and negative amounts:

const zeroAmount = amount(0, 'EUR');
const negativeAmount = amount(-50, 'GBP');
console.log(zeroAmount.isPositive()); // false
console.log(negativeAmount.isPositive()); // false

Works with decimal values:

const smallPositive = amount(0.01, 'USD');
const smallNegative = amount(-0.01, 'USD');
console.log(smallPositive.isPositive()); // true
console.log(smallNegative.isPositive()); // false

Useful 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"

Project

Built with by Jo Santana in Brazil.

© 2026 Inpulse. All rights reserved.