Check whether a Dinero object is positive.
Copy linkParameters
Name | Type | Description | Required |
---|---|---|---|
dineroObject | Dinero<TAmount> | The Dinero object to check. | Yes |
Copy linkCode examples
Copy linkCheck a positive object
import { dinero, isPositive } from 'dinero.js';
import { USD } from '@dinero.js/currencies';
const d = dinero({ amount: 100, currency: USD });
isPositive(d); // true
Copy linkCheck a negative object
import { dinero, isPositive } from 'dinero.js';
import { USD } from '@dinero.js/currencies';
const d = dinero({ amount: -100, currency: USD });
isPositive(d); // false
Copy linkCheck a zero object
import { dinero, isPositive } from 'dinero.js';
import { USD } from '@dinero.js/currencies';
const d = dinero({ amount: 0, currency: USD });
isPositive(d); // true