diff --git a/.changeset/nine-mangos-doubt.md b/.changeset/nine-mangos-doubt.md new file mode 100644 index 000000000..a13d76c41 --- /dev/null +++ b/.changeset/nine-mangos-doubt.md @@ -0,0 +1,5 @@ +--- +"@effect/schema": patch +--- + +add missing Forbidden handling diff --git a/src/Parser.ts b/src/Parser.ts index ad5220495..5a9fbbfee 100644 --- a/src/Parser.ts +++ b/src/Parser.ts @@ -313,7 +313,8 @@ const go = untracedMethod(() => options ) } else { - return (a, options) => PR.flatMap(ast.decode(a, options), (i2) => to(i2, options)) + return (a, options) => + handleForbidden(PR.flatMap(ast.decode(a, options), (i2) => to(i2, options)), options) } } case "Declaration": { diff --git a/src/TreeFormatter.ts b/src/TreeFormatter.ts index e1ac670a6..1e1a5f269 100644 --- a/src/TreeFormatter.ts +++ b/src/TreeFormatter.ts @@ -94,7 +94,11 @@ const getDescription = AST.getAnnotation( ) const getExpected = (ast: AST.AST): O.Option => - pipe(getIdentifier(ast), O.orElse(() => getTitle(ast)), O.orElse(() => getDescription(ast))) + pipe( + getIdentifier(ast), + O.orElse(() => getTitle(ast)), + O.orElse(() => getDescription(ast)) + ) /** @internal */ export const formatExpected = (ast: AST.AST): string => { @@ -110,43 +114,34 @@ export const formatExpected = (ast: AST.AST): string => { case "UnknownKeyword": case "VoidKeyword": case "NeverKeyword": - return pipe(getExpected(ast), O.getOrElse(() => ast._tag)) + return O.getOrElse(getExpected(ast), () => ast._tag) case "Literal": - return pipe(getExpected(ast), O.getOrElse(() => formatActual(ast.literal))) + return O.getOrElse(getExpected(ast), () => formatActual(ast.literal)) case "UniqueSymbol": - return pipe(getExpected(ast), O.getOrElse(() => formatActual(ast.symbol))) + return O.getOrElse(getExpected(ast), () => formatActual(ast.symbol)) case "Union": return ast.types.map(formatExpected).join(" or ") case "TemplateLiteral": - return pipe(getExpected(ast), O.getOrElse(() => formatTemplateLiteral(ast))) + return O.getOrElse(getExpected(ast), () => formatTemplateLiteral(ast)) case "Tuple": - return pipe(getExpected(ast), O.getOrElse(() => "")) + return O.getOrElse(getExpected(ast), () => "") case "TypeLiteral": - return pipe(getExpected(ast), O.getOrElse(() => "")) + return O.getOrElse(getExpected(ast), () => "") case "Enums": - return pipe( + return O.getOrElse( getExpected(ast), - O.getOrElse(() => ast.enums.map((_, value) => JSON.stringify(value)).join(" | ")) + () => ast.enums.map((_, value) => JSON.stringify(value)).join(" | ") ) case "Lazy": - return pipe( - getExpected(ast), - O.getOrElse(() => "") - ) + return O.getOrElse(getExpected(ast), () => "") case "Declaration": - return pipe( - getExpected(ast), - O.getOrElse(() => "") - ) + return O.getOrElse(getExpected(ast), () => "") case "Refinement": - return pipe( - getExpected(ast), - O.getOrElse(() => "") - ) + return O.getOrElse(getExpected(ast), () => "") case "Transform": - return pipe( + return O.getOrElse( getExpected(ast), - O.getOrElse(() => `${formatExpected(ast.from)} -> ${formatExpected(ast.to)}`) + () => `${formatExpected(ast.from)} -> ${formatExpected(ast.to)}` ) } }