(
minimum: BigDecimal_.BigDecimal,
annotations?: Annotations.Filter
): SchemaAST.Filter<BigDecimal_.BigDecimal>Validates that a BigDecimal is greater than or equal to the specified value (inclusive).
export const const isGreaterThanOrEqualToBigDecimal: (
minimum: BigDecimal_.BigDecimal,
annotations?: Annotations.Filter
) => SchemaAST.Filter<BigDecimal_.BigDecimal>
Validates that a BigDecimal is greater than or equal to the specified value
(inclusive).
isGreaterThanOrEqualToBigDecimal = function makeIsGreaterThanOrEqualTo<
T
>(options: {
readonly order: Order.Order<T>
readonly annotate?:
| ((
exclusiveMinimum: T
) => Annotations.Filter)
| undefined
readonly formatter?: Formatter<T> | undefined
}): (
minimum: T,
annotations?: Annotations.Filter
) => SchemaAST.Filter<T>
Creates a greater-than-or-equal-to (>=) check for any ordered type from an
Order.Order instance.
makeIsGreaterThanOrEqualTo({
order: Order.Order<BigDecimal_.BigDecimal>order: import BigDecimal_BigDecimal_.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,
formatter?: | Formatter<BigDecimal_.BigDecimal, string>
| undefined
formatter: (bd: BigDecimal_.BigDecimal(parameter) bd: {
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;
}
bd) => import BigDecimal_BigDecimal_.const format: (n: BigDecimal) => stringFormats a BigDecimal as a string.
When to use
Use to render a BigDecimal as plain decimal text when possible.
Details
The value is normalized before formatting. Scientific notation is used when
the absolute value of the normalized scale is at least 16; otherwise plain
decimal notation is used.
Example (Formatting decimals)
import { BigDecimal } from "effect"
import * as assert from "node:assert"
assert.deepStrictEqual(BigDecimal.format(BigDecimal.fromStringUnsafe("-5")), "-5")
assert.deepStrictEqual(BigDecimal.format(BigDecimal.fromStringUnsafe("123.456")), "123.456")
assert.deepStrictEqual(BigDecimal.format(BigDecimal.fromStringUnsafe("-0.00000123")), "-0.00000123")
format(bd: BigDecimal_.BigDecimal(parameter) bd: {
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;
}
bd)
})