effect 3.13.7 → 3.13.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/ParseResult.js +14 -8
- package/dist/cjs/ParseResult.js.map +1 -1
- package/dist/cjs/Schema.js +5 -3
- package/dist/cjs/Schema.js.map +1 -1
- package/dist/cjs/internal/version.js +1 -1
- package/dist/dts/Schema.d.ts +1 -1
- package/dist/dts/Schema.d.ts.map +1 -1
- package/dist/esm/ParseResult.js +14 -8
- package/dist/esm/ParseResult.js.map +1 -1
- package/dist/esm/Schema.js +5 -3
- package/dist/esm/Schema.js.map +1 -1
- package/dist/esm/internal/version.js +1 -1
- package/package.json +1 -1
- package/src/ParseResult.ts +16 -9
- package/src/Schema.ts +6 -3
- package/src/internal/version.ts +1 -1
package/package.json
CHANGED
package/src/ParseResult.ts
CHANGED
|
@@ -2015,7 +2015,7 @@ const makeArrayFormatterIssue = (
|
|
|
2015
2015
|
* @since 3.10.0
|
|
2016
2016
|
*/
|
|
2017
2017
|
export const ArrayFormatter: ParseResultFormatter<Array<ArrayFormatterIssue>> = {
|
|
2018
|
-
formatIssue: (issue) => getArrayFormatterIssues(issue),
|
|
2018
|
+
formatIssue: (issue) => getArrayFormatterIssues(issue, undefined, []),
|
|
2019
2019
|
formatIssueSync: (issue) => {
|
|
2020
2020
|
const e = ArrayFormatter.formatIssue(issue)
|
|
2021
2021
|
return isEither(e) ? Either.getOrThrow(e) : Effect.runSync(e)
|
|
@@ -2026,12 +2026,13 @@ export const ArrayFormatter: ParseResultFormatter<Array<ArrayFormatterIssue>> =
|
|
|
2026
2026
|
|
|
2027
2027
|
const getArrayFormatterIssues = (
|
|
2028
2028
|
issue: ParseIssue,
|
|
2029
|
-
|
|
2029
|
+
parentTag: ArrayFormatterIssue["_tag"] | undefined,
|
|
2030
|
+
path: ReadonlyArray<PropertyKey>
|
|
2030
2031
|
): Effect.Effect<Array<ArrayFormatterIssue>> => {
|
|
2031
2032
|
const _tag = issue._tag
|
|
2032
2033
|
switch (_tag) {
|
|
2033
2034
|
case "Type":
|
|
2034
|
-
return map(formatTypeMessage(issue), (message) => [makeArrayFormatterIssue(_tag, path, message)])
|
|
2035
|
+
return map(formatTypeMessage(issue), (message) => [makeArrayFormatterIssue(parentTag ?? _tag, path, message)])
|
|
2035
2036
|
case "Forbidden":
|
|
2036
2037
|
return Either.right([makeArrayFormatterIssue(_tag, path, formatForbiddenMessage(issue))])
|
|
2037
2038
|
case "Unexpected":
|
|
@@ -2039,23 +2040,29 @@ const getArrayFormatterIssues = (
|
|
|
2039
2040
|
case "Missing":
|
|
2040
2041
|
return map(formatMissingMessage(issue), (message) => [makeArrayFormatterIssue(_tag, path, message)])
|
|
2041
2042
|
case "Pointer":
|
|
2042
|
-
return getArrayFormatterIssues(issue.issue, path.concat(issue.path))
|
|
2043
|
+
return getArrayFormatterIssues(issue.issue, undefined, path.concat(issue.path))
|
|
2043
2044
|
case "Composite":
|
|
2044
2045
|
return flatMap(getMessage(issue), (message) => {
|
|
2045
2046
|
if (message !== undefined) {
|
|
2046
|
-
return Either.right([makeArrayFormatterIssue(
|
|
2047
|
+
return Either.right([makeArrayFormatterIssue(_tag, path, message)])
|
|
2047
2048
|
}
|
|
2048
2049
|
return util_.isNonEmpty(issue.issues)
|
|
2049
|
-
? map(Effect.forEach(issue.issues, (issue) => getArrayFormatterIssues(issue, path)), Arr.flatten)
|
|
2050
|
-
: getArrayFormatterIssues(issue.issues, path)
|
|
2050
|
+
? map(Effect.forEach(issue.issues, (issue) => getArrayFormatterIssues(issue, undefined, path)), Arr.flatten)
|
|
2051
|
+
: getArrayFormatterIssues(issue.issues, undefined, path)
|
|
2051
2052
|
})
|
|
2052
2053
|
case "Refinement":
|
|
2054
|
+
return flatMap(getMessage(issue), (message) => {
|
|
2055
|
+
if (message !== undefined) {
|
|
2056
|
+
return Either.right([makeArrayFormatterIssue(_tag, path, message)])
|
|
2057
|
+
}
|
|
2058
|
+
return getArrayFormatterIssues(issue.issue, issue.kind === "Predicate" ? _tag : undefined, path)
|
|
2059
|
+
})
|
|
2053
2060
|
case "Transformation":
|
|
2054
2061
|
return flatMap(getMessage(issue), (message) => {
|
|
2055
2062
|
if (message !== undefined) {
|
|
2056
|
-
return Either.right([makeArrayFormatterIssue(
|
|
2063
|
+
return Either.right([makeArrayFormatterIssue(_tag, path, message)])
|
|
2057
2064
|
}
|
|
2058
|
-
return getArrayFormatterIssues(issue.issue, path)
|
|
2065
|
+
return getArrayFormatterIssues(issue.issue, issue.kind === "Transformation" ? _tag : undefined, path)
|
|
2059
2066
|
})
|
|
2060
2067
|
}
|
|
2061
2068
|
}
|
package/src/Schema.ts
CHANGED
|
@@ -192,8 +192,11 @@ const makeStandardFailureFromParseIssue = (
|
|
|
192
192
|
* @category Standard Schema
|
|
193
193
|
* @since 3.13.0
|
|
194
194
|
*/
|
|
195
|
-
export const standardSchemaV1 = <A, I>(
|
|
196
|
-
|
|
195
|
+
export const standardSchemaV1 = <A, I>(
|
|
196
|
+
schema: Schema<A, I, never>,
|
|
197
|
+
overrideOptions?: AST.ParseOptions
|
|
198
|
+
): StandardSchemaV1<I, A> => {
|
|
199
|
+
const decodeUnknown = ParseResult.decodeUnknown(schema, { errors: "all" })
|
|
197
200
|
return {
|
|
198
201
|
"~standard": {
|
|
199
202
|
version: 1,
|
|
@@ -201,7 +204,7 @@ export const standardSchemaV1 = <A, I>(schema: Schema<A, I, never>): StandardSch
|
|
|
201
204
|
validate(value) {
|
|
202
205
|
const scheduler = new scheduler_.SyncScheduler()
|
|
203
206
|
const fiber = Effect.runFork(
|
|
204
|
-
Effect.matchEffect(decodeUnknown(value), {
|
|
207
|
+
Effect.matchEffect(decodeUnknown(value, overrideOptions), {
|
|
205
208
|
onFailure: makeStandardFailureFromParseIssue,
|
|
206
209
|
onSuccess: (value) => Effect.succeed({ value })
|
|
207
210
|
}),
|
package/src/internal/version.ts
CHANGED