BigDecimalType-level representation of BigDecimal.
export interface BigDecimal extends interface declare<T, Iso = T>Creates a schema for a non-parametric opaque type using a type-guard
function. The schema accepts any unknown value and succeeds when is returns
true, failing with an InvalidType issue otherwise.
When to use
Use when you are defining a schema for an opaque type with no type parameters
and validation can be expressed as a type guard.
Example (Defining a schema for a custom UserId branded type)
import { Schema } from "effect"
type UserId = string & { readonly _tag: "UserId" }
const isUserId = (u: unknown): u is UserId =>
typeof u === "string" && u.startsWith("user_")
const UserId = Schema.declare<UserId>(isUserId, {
title: "UserId",
description: "A user identifier starting with 'user_'"
})
Type-level representation returned by
declare
.
declare<import BigDecimal_BigDecimal_.type BigDecimal_.BigDecimal = /*unresolved*/ anyBigDecimal> {
readonly "Rebuild": BigDecimal
}
const const BigDecimalString: Stringconst BigDecimalString: {
Rebuild: Rebuild;
Iso: Iso;
ast: Ast;
Type: T;
Encoded: E;
DecodingServices: RD;
EncodingServices: RE;
annotate: (annotations: Annotations.Bottom<string, readonly []>) => String;
annotateKey: (annotations: Annotations.Key<string>) => String;
check: (checks_0: SchemaAST.Check<string>, ...checks: Array<SchemaAST.Check<string>>) => String;
rebuild: (ast: SchemaAST.String) => String;
make: (input: string, options?: MakeOptions) => string;
makeOption: (input: string, options?: MakeOptions) => Option_.Option<string>;
makeEffect: (input: string, options?: MakeOptions) => Effect.Effect<string, SchemaError, never>;
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; <…;
}
BigDecimalString = const String: Stringconst String: {
Rebuild: Rebuild;
Iso: Iso;
ast: Ast;
Type: T;
Encoded: E;
DecodingServices: RD;
EncodingServices: RE;
annotate: (annotations: Annotations.Bottom<string, readonly []>) => String;
annotateKey: (annotations: Annotations.Key<string>) => String;
check: (checks_0: SchemaAST.Check<string>, ...checks: Array<SchemaAST.Check<string>>) => String;
rebuild: (ast: SchemaAST.String) => String;
make: (input: string, options?: MakeOptions) => string;
makeOption: (input: string, options?: MakeOptions) => Option_.Option<string>;
makeEffect: (input: string, options?: MakeOptions) => Effect.Effect<string, SchemaError, never>;
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; <…;
}
Type-level representation of
String
.
Schema for string values. Validates that the input is typeof "string".
String.Bottom<string, string, never, never, String, String, string, string, readonly [], string, "readonly", "required", "no-default", "readonly", "required">.annotate(annotations: Annotations.Bottom<string, readonly []>): Stringannotate({ Annotations.Augment.expected?: string | undefinedHuman-readable description of what a value is expected to satisfy.
Details
For filter and refinement failures, the default formatter uses
message first, then expected, and finally falls back to <filter>.
Use this to name a failed filter in the default message:
Expected <expected>, got <actual>.
expected: "a string that will be decoded as a BigDecimal" })
const const bigDecimalDefaultMaxScale: 20bigDecimalDefaultMaxScale = 20
const const bigDecimalInvalidOrderedConstraintsError: "Unable to derive an arbitrary for the ordered BigDecimal constraints"bigDecimalInvalidOrderedConstraintsError = "Unable to derive an arbitrary for the ordered BigDecimal constraints"
function function bigDecimalScaleValueAtScale(
bd: BigDecimal_.BigDecimal,
scale: number
): bigint
bigDecimalScaleValueAtScale(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_.type BigDecimal_.BigDecimal = /*unresolved*/ anyBigDecimal, scale: numberscale: number): bigint {
return import BigDecimal_BigDecimal_.scale(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, scale: numberscale).value
}
function function bigDecimalMinValueAtScale(
minimum: BigDecimal_.BigDecimal,
scale: number,
excluded: boolean
): bigint
bigDecimalMinValueAtScale(
minimum: BigDecimal_.BigDecimal(parameter) 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: import BigDecimal_BigDecimal_.type BigDecimal_.BigDecimal = /*unresolved*/ anyBigDecimal,
scale: numberscale: number,
excluded: booleanexcluded: boolean
): bigint {
return excluded: booleanexcluded
? function bigDecimalScaleValueAtScale(
bd: BigDecimal_.BigDecimal,
scale: number
): bigint
bigDecimalScaleValueAtScale(import BigDecimal_BigDecimal_.floor(minimum: BigDecimal_.BigDecimal(parameter) 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, scale: numberscale), scale: numberscale) + module globalThisglobalThis.var BigInt: BigIntConstructor
;(value: bigint | boolean | number | string) =>
bigint
BigInt(1)
: function bigDecimalScaleValueAtScale(
bd: BigDecimal_.BigDecimal,
scale: number
): bigint
bigDecimalScaleValueAtScale(import BigDecimal_BigDecimal_.ceil(minimum: BigDecimal_.BigDecimal(parameter) 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, scale: numberscale), scale: numberscale)
}
function function bigDecimalMaxValueAtScale(
maximum: BigDecimal_.BigDecimal,
scale: number,
excluded: boolean
): bigint
bigDecimalMaxValueAtScale(
maximum: BigDecimal_.BigDecimal(parameter) 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: import BigDecimal_BigDecimal_.type BigDecimal_.BigDecimal = /*unresolved*/ anyBigDecimal,
scale: numberscale: number,
excluded: booleanexcluded: boolean
): bigint {
return excluded: booleanexcluded
? function bigDecimalScaleValueAtScale(
bd: BigDecimal_.BigDecimal,
scale: number
): bigint
bigDecimalScaleValueAtScale(import BigDecimal_BigDecimal_.ceil(maximum: BigDecimal_.BigDecimal(parameter) 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, scale: numberscale), scale: numberscale) - module globalThisglobalThis.var BigInt: BigIntConstructor
;(value: bigint | boolean | number | string) =>
bigint
BigInt(1)
: function bigDecimalScaleValueAtScale(
bd: BigDecimal_.BigDecimal,
scale: number
): bigint
bigDecimalScaleValueAtScale(import BigDecimal_BigDecimal_.floor(maximum: BigDecimal_.BigDecimal(parameter) 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, scale: numberscale), scale: numberscale)
}
function function bigDecimalMaxScale(
ordered: Annotations.ToArbitrary.OrderedConstraint<BigDecimal_.BigDecimal>
): number
bigDecimalMaxScale(ordered: Annotations.ToArbitrary.OrderedConstraint<BigDecimal_.BigDecimal>(parameter) ordered: {
order: Order.Order<T>;
minimum: T | undefined;
exclusiveMinimum: boolean | undefined;
maximum: T | undefined;
exclusiveMaximum: boolean | undefined;
}
ordered: Annotations.namespace Annotations.ToArbitraryTypes used by arbitrary-derivation annotations to configure toArbitrary
hooks, filter hints, candidate sources, diagnostics, and merged generation
constraints.
ToArbitrary.interface Annotations.ToArbitrary.OrderedConstraint<T>Ordered constraint accumulated from range checks.
Details
Generators consume these constraints only when they recognize order,
such as Order.Number, Order.BigInt, DateTime, or BigDecimal. Merging
constraints with different Order instances fails fast.
OrderedConstraint<import BigDecimal_BigDecimal_.type BigDecimal_.BigDecimal = /*unresolved*/ anyBigDecimal>): number {
return var Math: MathAn intrinsic object that provides basic mathematics functionality and constants.
Math.Math.max(...values: number[]): numberReturns the larger of a set of supplied numeric expressions.
max(
const bigDecimalDefaultMaxScale: 20bigDecimalDefaultMaxScale,
ordered: Annotations.ToArbitrary.OrderedConstraint<BigDecimal_.BigDecimal>(parameter) ordered: {
order: Order.Order<T>;
minimum: T | undefined;
exclusiveMinimum: boolean | undefined;
maximum: T | undefined;
exclusiveMaximum: boolean | undefined;
}
ordered.Annotations.ToArbitrary.OrderedConstraint<BigDecimal_.BigDecimal>.minimum?: anyminimum?.scale ?? 0,
ordered: Annotations.ToArbitrary.OrderedConstraint<BigDecimal_.BigDecimal>(parameter) ordered: {
order: Order.Order<T>;
minimum: T | undefined;
exclusiveMinimum: boolean | undefined;
maximum: T | undefined;
exclusiveMaximum: boolean | undefined;
}
ordered.Annotations.ToArbitrary.OrderedConstraint<BigDecimal_.BigDecimal>.maximum?: anymaximum?.scale ?? 0,
ordered: Annotations.ToArbitrary.OrderedConstraint<BigDecimal_.BigDecimal>(parameter) ordered: {
order: Order.Order<T>;
minimum: T | undefined;
exclusiveMinimum: boolean | undefined;
maximum: T | undefined;
exclusiveMaximum: boolean | undefined;
}
ordered.Annotations.ToArbitrary.OrderedConstraint<T>.exclusiveMinimum?: boolean | undefinedexclusiveMinimum && ordered: Annotations.ToArbitrary.OrderedConstraint<BigDecimal_.BigDecimal>(parameter) ordered: {
order: Order.Order<T>;
minimum: T | undefined;
exclusiveMinimum: boolean | undefined;
maximum: T | undefined;
exclusiveMaximum: boolean | undefined;
}
ordered.Annotations.ToArbitrary.OrderedConstraint<BigDecimal_.BigDecimal>.minimum?: anyminimum !== var undefinedundefined ? ordered: Annotations.ToArbitrary.OrderedConstraint<BigDecimal_.BigDecimal>(parameter) ordered: {
order: Order.Order<T>;
minimum: T | undefined;
exclusiveMinimum: boolean | undefined;
maximum: T | undefined;
exclusiveMaximum: boolean | undefined;
}
ordered.Annotations.ToArbitrary.OrderedConstraint<BigDecimal_.BigDecimal>.minimum?: any(property) Annotations.ToArbitrary.OrderedConstraint<BigDecimal_.BigDecimal>.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.scale + 1 : 0,
ordered: Annotations.ToArbitrary.OrderedConstraint<BigDecimal_.BigDecimal>(parameter) ordered: {
order: Order.Order<T>;
minimum: T | undefined;
exclusiveMinimum: boolean | undefined;
maximum: T | undefined;
exclusiveMaximum: boolean | undefined;
}
ordered.Annotations.ToArbitrary.OrderedConstraint<T>.exclusiveMaximum?: boolean | undefinedexclusiveMaximum && ordered: Annotations.ToArbitrary.OrderedConstraint<BigDecimal_.BigDecimal>(parameter) ordered: {
order: Order.Order<T>;
minimum: T | undefined;
exclusiveMinimum: boolean | undefined;
maximum: T | undefined;
exclusiveMaximum: boolean | undefined;
}
ordered.Annotations.ToArbitrary.OrderedConstraint<BigDecimal_.BigDecimal>.maximum?: anymaximum !== var undefinedundefined ? ordered: Annotations.ToArbitrary.OrderedConstraint<BigDecimal_.BigDecimal>(parameter) ordered: {
order: Order.Order<T>;
minimum: T | undefined;
exclusiveMinimum: boolean | undefined;
maximum: T | undefined;
exclusiveMaximum: boolean | undefined;
}
ordered.Annotations.ToArbitrary.OrderedConstraint<BigDecimal_.BigDecimal>.maximum?: any(property) Annotations.ToArbitrary.OrderedConstraint<BigDecimal_.BigDecimal>.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.scale + 1 : 0
)
}
function function bigDecimalValueConstraintsAtScale(
ordered: Annotations.ToArbitrary.OrderedConstraint<BigDecimal_.BigDecimal>,
scale: number
): FastCheck.BigIntConstraints | undefined
bigDecimalValueConstraintsAtScale(
ordered: Annotations.ToArbitrary.OrderedConstraint<BigDecimal_.BigDecimal>(parameter) ordered: {
order: Order.Order<T>;
minimum: T | undefined;
exclusiveMinimum: boolean | undefined;
maximum: T | undefined;
exclusiveMaximum: boolean | undefined;
}
ordered: Annotations.namespace Annotations.ToArbitraryTypes used by arbitrary-derivation annotations to configure toArbitrary
hooks, filter hints, candidate sources, diagnostics, and merged generation
constraints.
ToArbitrary.interface Annotations.ToArbitrary.OrderedConstraint<T>Ordered constraint accumulated from range checks.
Details
Generators consume these constraints only when they recognize order,
such as Order.Number, Order.BigInt, DateTime, or BigDecimal. Merging
constraints with different Order instances fails fast.
OrderedConstraint<import BigDecimal_BigDecimal_.type BigDecimal_.BigDecimal = /*unresolved*/ anyBigDecimal>,
scale: numberscale: number
): import FastCheckFastCheck.type FastCheck.BigIntConstraints = /*unresolved*/ anyBigIntConstraints | undefined {
const const constraints: FastCheck.BigIntConstraintsconstraints: import FastCheckFastCheck.type FastCheck.BigIntConstraints = /*unresolved*/ anyBigIntConstraints = {}
if (ordered: Annotations.ToArbitrary.OrderedConstraint<BigDecimal_.BigDecimal>(parameter) ordered: {
order: Order.Order<T>;
minimum: T | undefined;
exclusiveMinimum: boolean | undefined;
maximum: T | undefined;
exclusiveMaximum: boolean | undefined;
}
ordered.Annotations.ToArbitrary.OrderedConstraint<BigDecimal_.BigDecimal>.minimum?: anyminimum !== var undefinedundefined) {
const constraints: FastCheck.BigIntConstraintsconstraints.min = function bigDecimalMinValueAtScale(
minimum: BigDecimal_.BigDecimal,
scale: number,
excluded: boolean
): bigint
bigDecimalMinValueAtScale(ordered: Annotations.ToArbitrary.OrderedConstraint<BigDecimal_.BigDecimal>(parameter) ordered: {
order: Order.Order<T>;
minimum: T | undefined;
exclusiveMinimum: boolean | undefined;
maximum: T | undefined;
exclusiveMaximum: boolean | undefined;
}
ordered.Annotations.ToArbitrary.OrderedConstraint<BigDecimal_.BigDecimal>.minimum?: any(property) Annotations.ToArbitrary.OrderedConstraint<BigDecimal_.BigDecimal>.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, scale: numberscale, ordered: Annotations.ToArbitrary.OrderedConstraint<BigDecimal_.BigDecimal>(parameter) ordered: {
order: Order.Order<T>;
minimum: T | undefined;
exclusiveMinimum: boolean | undefined;
maximum: T | undefined;
exclusiveMaximum: boolean | undefined;
}
ordered.Annotations.ToArbitrary.OrderedConstraint<T>.exclusiveMinimum?: boolean | undefinedexclusiveMinimum === true)
}
if (ordered: Annotations.ToArbitrary.OrderedConstraint<BigDecimal_.BigDecimal>(parameter) ordered: {
order: Order.Order<T>;
minimum: T | undefined;
exclusiveMinimum: boolean | undefined;
maximum: T | undefined;
exclusiveMaximum: boolean | undefined;
}
ordered.Annotations.ToArbitrary.OrderedConstraint<BigDecimal_.BigDecimal>.maximum?: anymaximum !== var undefinedundefined) {
const constraints: FastCheck.BigIntConstraintsconstraints.max = function bigDecimalMaxValueAtScale(
maximum: BigDecimal_.BigDecimal,
scale: number,
excluded: boolean
): bigint
bigDecimalMaxValueAtScale(ordered: Annotations.ToArbitrary.OrderedConstraint<BigDecimal_.BigDecimal>(parameter) ordered: {
order: Order.Order<T>;
minimum: T | undefined;
exclusiveMinimum: boolean | undefined;
maximum: T | undefined;
exclusiveMaximum: boolean | undefined;
}
ordered.Annotations.ToArbitrary.OrderedConstraint<BigDecimal_.BigDecimal>.maximum?: any(property) Annotations.ToArbitrary.OrderedConstraint<BigDecimal_.BigDecimal>.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, scale: numberscale, ordered: Annotations.ToArbitrary.OrderedConstraint<BigDecimal_.BigDecimal>(parameter) ordered: {
order: Order.Order<T>;
minimum: T | undefined;
exclusiveMinimum: boolean | undefined;
maximum: T | undefined;
exclusiveMaximum: boolean | undefined;
}
ordered.Annotations.ToArbitrary.OrderedConstraint<T>.exclusiveMaximum?: boolean | undefinedexclusiveMaximum === true)
}
if (const constraints: FastCheck.BigIntConstraintsconstraints.min !== var undefinedundefined && const constraints: FastCheck.BigIntConstraintsconstraints.max !== var undefinedundefined && const constraints: FastCheck.BigIntConstraintsconstraints.min > const constraints: FastCheck.BigIntConstraintsconstraints.max) {
return var undefinedundefined
}
return const constraints: FastCheck.BigIntConstraintsconstraints
}
function function bigDecimalScaleConstraints(
ordered: Annotations.ToArbitrary.OrderedConstraint<BigDecimal_.BigDecimal>
): FastCheck.IntegerConstraints
bigDecimalScaleConstraints(
ordered: Annotations.ToArbitrary.OrderedConstraint<BigDecimal_.BigDecimal>(parameter) ordered: {
order: Order.Order<T>;
minimum: T | undefined;
exclusiveMinimum: boolean | undefined;
maximum: T | undefined;
exclusiveMaximum: boolean | undefined;
}
ordered: Annotations.namespace Annotations.ToArbitraryTypes used by arbitrary-derivation annotations to configure toArbitrary
hooks, filter hints, candidate sources, diagnostics, and merged generation
constraints.
ToArbitrary.interface Annotations.ToArbitrary.OrderedConstraint<T>Ordered constraint accumulated from range checks.
Details
Generators consume these constraints only when they recognize order,
such as Order.Number, Order.BigInt, DateTime, or BigDecimal. Merging
constraints with different Order instances fails fast.
OrderedConstraint<import BigDecimal_BigDecimal_.type BigDecimal_.BigDecimal = /*unresolved*/ anyBigDecimal>
): import FastCheckFastCheck.type FastCheck.IntegerConstraints = /*unresolved*/ anyIntegerConstraints {
const const max: numbermax = function bigDecimalMaxScale(
ordered: Annotations.ToArbitrary.OrderedConstraint<BigDecimal_.BigDecimal>
): number
bigDecimalMaxScale(ordered: Annotations.ToArbitrary.OrderedConstraint<BigDecimal_.BigDecimal>(parameter) ordered: {
order: Order.Order<T>;
minimum: T | undefined;
exclusiveMinimum: boolean | undefined;
maximum: T | undefined;
exclusiveMaximum: boolean | undefined;
}
ordered)
if (function bigDecimalValueConstraintsAtScale(
ordered: Annotations.ToArbitrary.OrderedConstraint<BigDecimal_.BigDecimal>,
scale: number
): FastCheck.BigIntConstraints | undefined
bigDecimalValueConstraintsAtScale(ordered: Annotations.ToArbitrary.OrderedConstraint<BigDecimal_.BigDecimal>(parameter) ordered: {
order: Order.Order<T>;
minimum: T | undefined;
exclusiveMinimum: boolean | undefined;
maximum: T | undefined;
exclusiveMaximum: boolean | undefined;
}
ordered, const max: numbermax) === var undefinedundefined) {
throw new module globalThisglobalThis.var Error: ErrorConstructor
new (message?: string, options?: globalThis.ErrorOptions) => globalThis.Error (+1 overload)
Error(const bigDecimalInvalidOrderedConstraintsError: "Unable to derive an arbitrary for the ordered BigDecimal constraints"bigDecimalInvalidOrderedConstraintsError)
}
let let min: numbermin = 0
let let high: numberhigh = const max: numbermax
while (let min: numbermin < let high: numberhigh) {
const const scale: numberscale = let min: numbermin + var Math: MathAn intrinsic object that provides basic mathematics functionality and constants.
Math.Math.floor(x: number): numberReturns the greatest integer less than or equal to its numeric argument.
floor((let high: numberhigh - let min: numbermin) / 2)
if (function bigDecimalValueConstraintsAtScale(
ordered: Annotations.ToArbitrary.OrderedConstraint<BigDecimal_.BigDecimal>,
scale: number
): FastCheck.BigIntConstraints | undefined
bigDecimalValueConstraintsAtScale(ordered: Annotations.ToArbitrary.OrderedConstraint<BigDecimal_.BigDecimal>(parameter) ordered: {
order: Order.Order<T>;
minimum: T | undefined;
exclusiveMinimum: boolean | undefined;
maximum: T | undefined;
exclusiveMaximum: boolean | undefined;
}
ordered, const scale: numberscale) === var undefinedundefined) {
let min: numbermin = const scale: numberscale + 1
} else {
let high: numberhigh = const scale: numberscale
}
}
return { min: numbermin, max: numbermax }
}
/**
* Schema for `BigDecimal` values.
*
* **When to use**
*
* Use when you already have Effect decimal instances and need schema
* validation, formatting, equivalence, and JSON string serialization.
*
* **Details**
*
* Default JSON serializer:
*
* - encodes `BigDecimal` as a `string`
*
* @see {@link BigDecimalFromString} for parsing string input into a BigDecimal
*
* @category BigDecimal
* @since 3.10.0
*/
export const const BigDecimal: BigDecimalconst BigDecimal: {
Rebuild: BigDecimal;
Iso: Iso;
ast: Ast;
Type: T;
Encoded: E;
DecodingServices: RD;
EncodingServices: RE;
annotate: (annotations: Annotations.Bottom<BigDecimal_.BigDecimal, readonly []>) => BigDecimal;
annotateKey: (annotations: Annotations.Key<BigDecimal_.BigDecimal>) => BigDecimal;
check: (checks_0: SchemaAST.Check<BigDecimal_.BigDecimal>, ...checks: Array<SchemaAST.Check<BigDecimal_.BigDecimal>>) => BigDecimal;
rebuild: (ast: SchemaAST.Declaration) => BigDecimal;
make: (input: BigDecimal_.BigDecimal, options?: MakeOptions) => BigDecimal_.BigDecimal;
makeOption: (input: BigDecimal_.BigDecimal, options?: MakeOptions) => Option_.Option<BigDecimal_.BigDecimal>;
makeEffect: (input: BigDecimal_.BigDecimal, options?: MakeOptions) => Effect.Effect<BigDecimal_.BigDecimal, SchemaError, never>;
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; <…;
}
Type-level representation of
BigDecimal
.
Schema for BigDecimal values.
When to use
Use when you already have Effect decimal instances and need schema
validation, formatting, equivalence, and JSON string serialization.
Details
Default JSON serializer:
- encodes
BigDecimal as a string
BigDecimal: BigDecimal = function declare<T, Iso = T>(
is: (u: unknown) => u is T,
annotations?:
| Annotations.Declaration<T>
| undefined
): declare<T, Iso>
Creates a schema for a non-parametric opaque type using a type-guard
function. The schema accepts any unknown value and succeeds when is returns
true, failing with an InvalidType issue otherwise.
When to use
Use when you are defining a schema for an opaque type with no type parameters
and validation can be expressed as a type guard.
Example (Defining a schema for a custom UserId branded type)
import { Schema } from "effect"
type UserId = string & { readonly _tag: "UserId" }
const isUserId = (u: unknown): u is UserId =>
typeof u === "string" && u.startsWith("user_")
const UserId = Schema.declare<UserId>(isUserId, {
title: "UserId",
description: "A user identifier starting with 'user_'"
})
declare(
import BigDecimal_BigDecimal_.isBigDecimal,
{
Annotations.Declaration<BigDecimal_.BigDecimal, readonly []>.typeConstructor?: {
readonly [key: string]: unknown;
readonly _tag: string;
} | undefined
typeConstructor: {
_tag: string_tag: "effect/BigDecimal"
},
Annotations.Declaration<BigDecimal_.BigDecimal, readonly []>.generation?: {
readonly runtime: string;
readonly Type: string;
readonly Encoded?: string | undefined;
readonly importDeclaration?: string | undefined;
} | undefined
generation: {
runtime: stringruntime: `Schema.BigDecimal`,
type Type: stringType: `BigDecimal.BigDecimal`,
importDeclaration?: string | undefinedimportDeclaration: `import * as BigDecimal from "effect/BigDecimal"`
},
Annotations.Augment.expected?: string | undefinedHuman-readable description of what a value is expected to satisfy.
Details
For filter and refinement failures, the default formatter uses
message first, then expected, and finally falls back to <filter>.
Use this to name a failed filter in the default message:
Expected <expected>, got <actual>.
expected: "BigDecimal",
Annotations.Declaration<BigDecimal_.BigDecimal, readonly []>.toCodecJson?: ((typeParameters: readonly []) => SchemaAST.Link) | undefinedtoCodecJson: () =>
function link<T>(): <
To extends Constraint
>(
encodeTo: To,
transformation: {
readonly decode: SchemaGetter.Getter<
T,
NoInfer<To["Type"]>
>
readonly encode: SchemaGetter.Getter<
NoInfer<To["Type"]>,
T
>
}
) => SchemaAST.Link
Constructs an SchemaAST.Link that describes how a value of type T encodes to and decodes from a To schema.
Used when building low-level AST transformations that bridge two schema types.
link<import BigDecimal_BigDecimal_.type BigDecimal_.BigDecimal = /*unresolved*/ anyBigDecimal>()(
const BigDecimalString: Stringconst BigDecimalString: {
Rebuild: Rebuild;
Iso: Iso;
ast: Ast;
Type: T;
Encoded: E;
DecodingServices: RD;
EncodingServices: RE;
annotate: (annotations: Annotations.Bottom<string, readonly []>) => String;
annotateKey: (annotations: Annotations.Key<string>) => String;
check: (checks_0: SchemaAST.Check<string>, ...checks: Array<SchemaAST.Check<string>>) => String;
rebuild: (ast: SchemaAST.String) => String;
make: (input: string, options?: MakeOptions) => string;
makeOption: (input: string, options?: MakeOptions) => Option_.Option<string>;
makeEffect: (input: string, options?: MakeOptions) => Effect.Effect<string, SchemaError, never>;
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; <…;
}
BigDecimalString,
import SchemaTransformationSchemaTransformation.const bigDecimalFromString: Transformation<
BigDecimal.BigDecimal,
string
>
const bigDecimalFromString: {
_tag: 'Transformation';
decode: SchemaGetter.Getter<T, E, RD>;
encode: SchemaGetter.Getter<E, T, RE>;
flip: () => SchemaTransformation.Transformation<string, BigDecimal_.BigDecimal, never, never>;
compose: (other: SchemaTransformation.Transformation<T2, BigDecimal_.BigDecimal, RD2, RE2>) => SchemaTransformation.Transformation<T2, string, RD2, RE2>;
}
Decodes a string into a BigDecimal and encodes a BigDecimal back to
its string representation.
When to use
Use when you need a schema transformation to parse decimal number strings
from APIs or user input.
Details
Decoding calls BigDecimal.fromString(s) and fails with InvalidValue if
the string is not a valid BigDecimal representation. Encoding returns
BigDecimal.format(bd).
bigDecimalFromString
),
Annotations.Declaration<BigDecimal_.BigDecimal, readonly []>.toArbitrary?: Annotations.ToArbitrary.Declaration<BigDecimal_.BigDecimal, readonly []> | undefinedtoArbitrary: () => (fc: typeof FastCheckfc, ctx: Annotations.ToArbitrary.Context(parameter) ctx: {
constraint: ToArbitrary.GenerationConstraint | undefined;
recursion: ToArbitrary.Recursion | undefined;
}
ctx) => {
const const ordered:
| Annotations.ToArbitrary.OrderedConstraint<BigDecimal_.BigDecimal>
| undefined
ordered = ctx: Annotations.ToArbitrary.Context(parameter) ctx: {
constraint: ToArbitrary.GenerationConstraint | undefined;
recursion: ToArbitrary.Recursion | undefined;
}
ctx.Annotations.ToArbitrary.Context.constraint?: Annotations.ToArbitrary.GenerationConstraint | undefinedconstraint?.Annotations.ToArbitrary.GenerationConstraint.ordered?: Annotations.ToArbitrary.OrderedConstraint<any> | undefinedordered?.Annotations.ToArbitrary.OrderedConstraint<any>.order: Order.Order<T>order === import BigDecimal_BigDecimal_.Order
? ctx: Annotations.ToArbitrary.Context(parameter) ctx: {
constraint: ToArbitrary.GenerationConstraint | undefined;
recursion: ToArbitrary.Recursion | undefined;
}
ctx.Annotations.ToArbitrary.Context.constraint?: Annotations.ToArbitrary.GenerationConstraint | undefined(property) Annotations.ToArbitrary.Context.constraint?: {
minLength: number | undefined;
maxLength: number | undefined;
patterns: readonly [string, ...Array<string>];
integer: boolean | undefined;
noInfinity: boolean | undefined;
noNaN: boolean | undefined;
valid: boolean | undefined;
unique: boolean | undefined;
ordered: OrderedConstraint<any> | undefined;
}
constraint.Annotations.ToArbitrary.GenerationConstraint.ordered?: Annotations.ToArbitrary.OrderedConstraint<any> | undefined(property) Annotations.ToArbitrary.GenerationConstraint.ordered?: {
order: Order.Order<T>;
minimum: T | undefined;
exclusiveMinimum: boolean | undefined;
maximum: T | undefined;
exclusiveMaximum: boolean | undefined;
}
ordered as Annotations.namespace Annotations.ToArbitraryTypes used by arbitrary-derivation annotations to configure toArbitrary
hooks, filter hints, candidate sources, diagnostics, and merged generation
constraints.
ToArbitrary.interface Annotations.ToArbitrary.OrderedConstraint<T>Ordered constraint accumulated from range checks.
Details
Generators consume these constraints only when they recognize order,
such as Order.Number, Order.BigInt, DateTime, or BigDecimal. Merging
constraints with different Order instances fails fast.
OrderedConstraint<import BigDecimal_BigDecimal_.type BigDecimal_.BigDecimal = /*unresolved*/ anyBigDecimal>
: var undefinedundefined
if (const ordered:
| Annotations.ToArbitrary.OrderedConstraint<BigDecimal_.BigDecimal>
| undefined
ordered === var undefinedundefined) {
return fc: typeof FastCheckfc.tuple(fc: typeof FastCheckfc.bigInt(), fc: typeof FastCheckfc.integer({ min: numbermin: 0, max: numbermax: const bigDecimalDefaultMaxScale: 20bigDecimalDefaultMaxScale }))
.map(([value: anyvalue, scale: anyscale]) => import BigDecimal_BigDecimal_.make(value: anyvalue, scale: anyscale))
}
return fc: typeof FastCheckfc.integer(function bigDecimalScaleConstraints(
ordered: Annotations.ToArbitrary.OrderedConstraint<BigDecimal_.BigDecimal>
): FastCheck.IntegerConstraints
bigDecimalScaleConstraints(const ordered: Annotations.ToArbitrary.OrderedConstraint<BigDecimal_.BigDecimal>const ordered: {
order: Order.Order<T>;
minimum: T | undefined;
exclusiveMinimum: boolean | undefined;
maximum: T | undefined;
exclusiveMaximum: boolean | undefined;
}
ordered)).chain((scale: anyscale) => {
const const constraints: anyconstraints = function bigDecimalValueConstraintsAtScale(
ordered: Annotations.ToArbitrary.OrderedConstraint<BigDecimal_.BigDecimal>,
scale: number
): FastCheck.BigIntConstraints | undefined
bigDecimalValueConstraintsAtScale(const ordered: Annotations.ToArbitrary.OrderedConstraint<BigDecimal_.BigDecimal>const ordered: {
order: Order.Order<T>;
minimum: T | undefined;
exclusiveMinimum: boolean | undefined;
maximum: T | undefined;
exclusiveMaximum: boolean | undefined;
}
ordered, scale: anyscale)
if (const constraints: anyconstraints === var undefinedundefined) {
throw new module globalThisglobalThis.var Error: ErrorConstructor
new (message?: string, options?: globalThis.ErrorOptions) => globalThis.Error (+1 overload)
Error(const bigDecimalInvalidOrderedConstraintsError: "Unable to derive an arbitrary for the ordered BigDecimal constraints"bigDecimalInvalidOrderedConstraintsError)
}
return fc: typeof FastCheckfc.bigInt(const constraints: anyconstraints).map((value: anyvalue) => import BigDecimal_BigDecimal_.make(value: anyvalue, scale: anyscale))
})
},
Annotations.Declaration<BigDecimal_.BigDecimal, readonly []>.toFormatter?: Annotations.ToFormatter.Declaration<BigDecimal_.BigDecimal, readonly []> | undefinedtoFormatter: () => (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_.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),
Annotations.Declaration<BigDecimal_.BigDecimal, readonly []>.toEquivalence?: Annotations.ToEquivalence.Declaration<BigDecimal_.BigDecimal, readonly []> | undefinedtoEquivalence: () => import BigDecimal_BigDecimal_.Equivalence
}
)