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

isNegative

boolean

Check whether a Dinero object is negative.

Copy linkParameters

NameTypeDescriptionRequired
dineroObjectDinero<TAmount>

The Dinero object to check.

Yes

Copy linkCode examples

Copy linkCheck a positive object

import { dinero, isNegative } from 'dinero.js';
import { USD } from '@dinero.js/currencies';

const d = dinero({ amount: 100, currency: USD });

isNegative(d); // false

Copy linkCheck a negative object

import { dinero, isNegative } from 'dinero.js';
import { USD } from '@dinero.js/currencies';

const d = dinero({ amount: -100, currency: USD });

isNegative(d); // true

Copy linkCheck a zero object

import { dinero, isNegative } from 'dinero.js';
import { USD } from '@dinero.js/currencies';

const d = dinero({ amount: 0, currency: USD });

isNegative(d); // false