Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/slimy-swans-repeat.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"effect": patch
---

Fix use of Schema.NonEmptyArrayEnsure with strings
2 changes: 1 addition & 1 deletion packages/effect/src/Schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1664,7 +1664,7 @@ export interface NonEmptyArrayEnsure<Value extends Schema.Any>
export function NonEmptyArrayEnsure<Value extends Schema.Any>(value: Value): NonEmptyArrayEnsure<Value> {
return transform(Union(value, NonEmptyArray(value)), NonEmptyArray(typeSchema(asSchema(value))), {
strict: true,
decode: (i) => array_.isNonEmptyReadonlyArray(i) ? i : array_.of(i),
decode: (i) => array_.ensure(i) as never,
encode: (a) => a.length === 1 ? a[0] : a
})
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@ import * as Util from "../TestUtils.js"
describe("NonEmptyArrayEnsure", () => {
it("decode non-array", async () => {
const schema = S.NonEmptyArrayEnsure(S.NumberFromString)
const schema2 = S.NonEmptyArrayEnsure(S.String)
await Util.assertions.decoding.succeed(schema, "123", [123])
await Util.assertions.decoding.succeed(schema2, "foo", ["foo"])
await Util.assertions.decoding.fail(
schema,
null,
Expand Down
Loading