Amount
isNegative
1.0.0- Dependencies:
- ∟Direct: 0
- ∟Peer: 0
- Source code ↗
- Check on NPM ↗
Hidden
Overview
Section titled “Overview”Checks if an amount is negative (less than zero) by comparing the internal cents value.
amount.isNegative();Features
Section titled “Features”- Returns a boolean value indicating if the amount is negative
- 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 isNegative() method to check if the amount is less than zero.
import { amount } from '@inpulse-ui/utils';
const negativeAmount = amount(-100, 'USD');const result = negativeAmount.isNegative();
console.log(result); // trueIt returns false for zero and positive amounts:
const zeroAmount = amount(0, 'EUR');const positiveAmount = amount(50, 'GBP');
console.log(zeroAmount.isNegative()); // falseconsole.log(positiveAmount.isNegative()); // falseWorks with decimal values:
const smallNegative = amount(-0.01, 'USD');const smallPositive = amount(0.01, 'USD');
console.log(smallNegative.isNegative()); // trueconsole.log(smallPositive.isNegative()); // falseUseful for conditional logic:
const balance = amount(-25.50, 'USD');
if (balance.isNegative()) { console.log('Account is overdrawn');} else { console.log('Account balance is zero or positive');}// Output: "Account is overdrawn"Validation for debt tracking:
const accountBalance = amount(-150.00, 'USD');
if (accountBalance.isNegative()) { console.log(`Outstanding debt: ${accountBalance.abs().format()}`); // Handle negative balance} else { console.log('No outstanding debt');}// Output: "Outstanding debt: $150.00"Built with by Jo Santana in Brazil.
© 2026 Inpulse. All rights reserved.