Skip to content
This repository has been archived by the owner on Jul 16, 2024. It is now read-only.

Commit

Permalink
updated readme
Browse files Browse the repository at this point in the history
  • Loading branch information
jessekelly881 committed Nov 23, 2023
1 parent a0fccb9 commit def3d22
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 2 deletions.
20 changes: 20 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -928,6 +928,26 @@ S.bigint.pipe(S.negativeBigint()); // < 0n
S.bigint.pipe(S.nonPositiveBigint()); // <= 0n
```

### BigDecimal filters

```ts
import * as S from "@effect/schema/Schema";
import * as BigDecimal from "effect/BigDecimal";

S.BigDecimal.pipe(S.greaterThanBigDecimal(BigDecimal.fromNumber(5)));
S.BigDecimal.pipe(S.greaterThanOrEqualToBigDecimal(BigDecimal.fromNumber(5)));
S.BigDecimal.pipe(S.lessThanBigDecimal(BigDecimal.fromNumber(5)));
S.BigDecimal.pipe(S.lessThanOrEqualToBigDecimal(BigDecimal.fromNumber(5)));
S.BigDecimal.pipe(
S.betweenBigDecimal(BigDecimal.fromNumber(-2), BigDecimal.fromNumber(2))
);

S.BigDecimal.pipe(S.positiveBigDecimal());
S.BigDecimal.pipe(S.nonNegativeBigDecimal());
S.BigDecimal.pipe(S.negativeBigDecimal());
S.BigDecimal.pipe(S.nonPositiveBigDecimal());
```

### Array filters

```ts
Expand Down
4 changes: 2 additions & 2 deletions src/Schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3569,7 +3569,7 @@ export const bigDecimalFromNumber = <I, A extends number>(
self,
BigDecimalFromSelf,
(num) => ParseResult.success(BigDecimal.fromNumber(num)),
(val) => ParseResult.success(BigDecimal.unsafeToNumber(val)), // TODO: Try to make this safe
(val) => ParseResult.success(BigDecimal.unsafeToNumber(val)), // Can this be made safe?
{ strict: false }
)

Expand All @@ -3590,7 +3590,7 @@ export const bigDecimalFromString = <I, A extends string>(
onNone: () => ParseResult.failure(ParseResult.type(BigDecimalFromSelf.ast, num)),
onSome: ParseResult.success
})),
(val) => ParseResult.success(BigDecimal.toString(val)), // TODO: Try to make this safe
(val) => ParseResult.success(BigDecimal.toString(val)),
{ strict: false }
)

Expand Down

0 comments on commit def3d22

Please sign in to comment.