(options: { minimum: BigDecimal; maximum: BigDecimal }): (
self: BigDecimal
) => boolean
(
self: BigDecimal,
options: { minimum: BigDecimal; maximum: BigDecimal }
): booleanChecks whether a BigDecimal is between a minimum and maximum value (inclusive).
When to use
Use to test whether a BigDecimal falls inside an inclusive range.
Example (Checking decimal ranges)
import { BigDecimal } from "effect"
import * as assert from "node:assert"
const between = BigDecimal.between({
minimum: BigDecimal.fromStringUnsafe("1"),
maximum: BigDecimal.fromStringUnsafe("5")
})
assert.deepStrictEqual(between(BigDecimal.fromStringUnsafe("3")), true)
assert.deepStrictEqual(between(BigDecimal.fromStringUnsafe("0")), false)
assert.deepStrictEqual(between(BigDecimal.fromStringUnsafe("6")), false)export const const between: {
(options: {
minimum: BigDecimal
maximum: BigDecimal
}): (self: BigDecimal) => boolean
(
self: BigDecimal,
options: {
minimum: BigDecimal
maximum: BigDecimal
}
): boolean
}
Checks whether a BigDecimal is between a minimum and maximum value (inclusive).
When to use
Use to test whether a BigDecimal falls inside an inclusive range.
Example (Checking decimal ranges)
import { BigDecimal } from "effect"
import * as assert from "node:assert"
const between = BigDecimal.between({
minimum: BigDecimal.fromStringUnsafe("1"),
maximum: BigDecimal.fromStringUnsafe("5")
})
assert.deepStrictEqual(between(BigDecimal.fromStringUnsafe("3")), true)
assert.deepStrictEqual(between(BigDecimal.fromStringUnsafe("0")), false)
assert.deepStrictEqual(between(BigDecimal.fromStringUnsafe("6")), false)
between: {
(options: {
minimum: BigDecimal
maximum: BigDecimal
}
options: {
minimum: BigDecimal(property) minimum: {
value: bigint;
scale: number;
normalized: BigDecimal;
pipe: { <A>(this: A): A; <A, B = never>(this: A, ab: (_: A) => B): B; <A, B = never, C = never>(this: A, ab: (_: A) => B, bc: (_: B) => C): C; <A, B = never, C = never, D = never>(this: A, ab: (_: A) => B, bc: (_: B) => C, cd: (_: C) => D): D; <…;
toString: () => string;
toJSON: () => unknown;
}
minimum: BigDecimal
maximum: BigDecimal(property) maximum: {
value: bigint;
scale: number;
normalized: BigDecimal;
pipe: { <A>(this: A): A; <A, B = never>(this: A, ab: (_: A) => B): B; <A, B = never, C = never>(this: A, ab: (_: A) => B, bc: (_: B) => C): C; <A, B = never, C = never, D = never>(this: A, ab: (_: A) => B, bc: (_: B) => C, cd: (_: C) => D): D; <…;
toString: () => string;
toJSON: () => unknown;
}
maximum: BigDecimal
}): (self: BigDecimal(parameter) self: {
value: bigint;
scale: number;
normalized: BigDecimal;
pipe: { <A>(this: A): A; <A, B = never>(this: A, ab: (_: A) => B): B; <A, B = never, C = never>(this: A, ab: (_: A) => B, bc: (_: B) => C): C; <A, B = never, C = never, D = never>(this: A, ab: (_: A) => B, bc: (_: B) => C, cd: (_: C) => D): D; <…;
toString: () => string;
toJSON: () => unknown;
}
self: BigDecimal) => boolean
(self: BigDecimal(parameter) self: {
value: bigint;
scale: number;
normalized: BigDecimal;
pipe: { <A>(this: A): A; <A, B = never>(this: A, ab: (_: A) => B): B; <A, B = never, C = never>(this: A, ab: (_: A) => B, bc: (_: B) => C): C; <A, B = never, C = never, D = never>(this: A, ab: (_: A) => B, bc: (_: B) => C, cd: (_: C) => D): D; <…;
toString: () => string;
toJSON: () => unknown;
}
self: BigDecimal, options: {
minimum: BigDecimal
maximum: BigDecimal
}
options: {
minimum: BigDecimal(property) minimum: {
value: bigint;
scale: number;
normalized: BigDecimal;
pipe: { <A>(this: A): A; <A, B = never>(this: A, ab: (_: A) => B): B; <A, B = never, C = never>(this: A, ab: (_: A) => B, bc: (_: B) => C): C; <A, B = never, C = never, D = never>(this: A, ab: (_: A) => B, bc: (_: B) => C, cd: (_: C) => D): D; <…;
toString: () => string;
toJSON: () => unknown;
}
minimum: BigDecimal
maximum: BigDecimal(property) maximum: {
value: bigint;
scale: number;
normalized: BigDecimal;
pipe: { <A>(this: A): A; <A, B = never>(this: A, ab: (_: A) => B): B; <A, B = never, C = never>(this: A, ab: (_: A) => B, bc: (_: B) => C): C; <A, B = never, C = never, D = never>(this: A, ab: (_: A) => B, bc: (_: B) => C, cd: (_: C) => D): D; <…;
toString: () => string;
toJSON: () => unknown;
}
maximum: BigDecimal
}): boolean
} = import orderorder.const isBetween: <A>(O: Order<A>) => {
(options: { minimum: A; maximum: A }): (
self: A
) => boolean
(
self: A,
options: { minimum: A; maximum: A }
): boolean
}
Checks whether a value is between a minimum and a maximum (inclusive) according to the given order.
When to use
Use when you need range checks that respect domain-specific ordering, such as
dates, versions, or custom priorities, instead of JavaScript numeric
comparison.
Details
Returns true when the value is greater than or equal to minimum and less
than or equal to maximum. Values outside the range return false. Both
bounds are inclusive.
Example (Checking ranges)
import { Order } from "effect"
const betweenNumber = Order.isBetween(Order.Number)
console.log(betweenNumber(5, { minimum: 1, maximum: 10 })) // true
console.log(betweenNumber(1, { minimum: 1, maximum: 10 })) // true
console.log(betweenNumber(10, { minimum: 1, maximum: 10 })) // true
console.log(betweenNumber(0, { minimum: 1, maximum: 10 })) // false
console.log(betweenNumber(11, { minimum: 1, maximum: 10 })) // false
isBetween(const Order: order.Order<BigDecimal>Provides an Order instance for BigDecimal that allows comparing and sorting BigDecimal values.
When to use
Use when you need to sort or compare decimal values through APIs that accept
an ordering instance.
Example (Comparing decimals)
import { BigDecimal } from "effect"
const a = BigDecimal.fromNumberUnsafe(1.5)
const b = BigDecimal.fromNumberUnsafe(2.3)
const c = BigDecimal.fromNumberUnsafe(1.5)
console.log(BigDecimal.Order(a, b)) // -1 (a < b)
console.log(BigDecimal.Order(b, a)) // 1 (b > a)
console.log(BigDecimal.Order(a, c)) // 0 (a === c)
Order)