Click here for v1.x documentation.
Dinero.js
Dinero.js version

isPositive

boolean

Check whether a Dinero object is positive.

Copy linkParameters

NameTypeDescriptionRequired
dineroObjectDinero<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); // false