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

Commit

Permalink
AST: simplify createRefinement return type
Browse files Browse the repository at this point in the history
  • Loading branch information
gcanti committed Dec 29, 2023
1 parent bcd6931 commit b40bad8
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 12 deletions.
5 changes: 5 additions & 0 deletions .changeset/friendly-drinks-double.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@effect/schema": minor
---

AST: simplify `createRefinement` return type
2 changes: 1 addition & 1 deletion docs/modules/AST.ts.md
Original file line number Diff line number Diff line change
Expand Up @@ -601,7 +601,7 @@ export declare const createRefinement: <From extends AST>(
from: From,
filter: Refinement["filter"],
annotations?: Annotated["annotations"]
) => Transform | Refinement<From>
) => Refinement<From>
```
Added in v1.0.0
Expand Down
10 changes: 1 addition & 9 deletions src/AST.ts
Original file line number Diff line number Diff line change
Expand Up @@ -957,15 +957,7 @@ export const createRefinement = <From extends AST>(
from: From,
filter: Refinement["filter"],
annotations: Annotated["annotations"] = {}
): Refinement<From> | Transform => {
if (isTransform(from)) {
// recurse right
return createTransform(
from.from,
createRefinement(from.to, filter, annotations),
from.transformation
)
}
): Refinement<From> => {
return { _tag: "Refinement", from, filter, annotations }
}

Expand Down
4 changes: 2 additions & 2 deletions test/Schema/required.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,14 @@ describe("Schema > required", () => {
await Util.expectParseFailure(
schema,
{},
`{ a: <transformation string <-> a positive number> }
`{ a: a positive number }
└─ ["a"]
└─ is missing`
)
await Util.expectParseFailure(
schema,
{ a: "-1" },
`{ a: <transformation string <-> a positive number> }
`{ a: a positive number }
└─ ["a"]
└─ Expected a positive number, actual -1`
)
Expand Down

0 comments on commit b40bad8

Please sign in to comment.