@effect/schema
Advanced tools
Comparing version 0.73.2 to 0.73.3
@@ -610,6 +610,20 @@ "use strict"; | ||
const from = goMemo(ast.from, true); | ||
return (i, options) => handleForbidden(flatMap(mapError(from(i, options), e => new Refinement(ast, i, "From", e)), a => Option.match(ast.filter(a, options ?? AST.defaultParseOption, ast), { | ||
onNone: () => Either.right(a), | ||
onSome: e => Either.left(new Refinement(ast, i, "Predicate", e)) | ||
})), ast, i, options); | ||
return (i, options) => { | ||
options = options ?? AST.defaultParseOption; | ||
const allErrors = options?.errors === "all"; | ||
const result = flatMap(orElse(from(i, options), ef => { | ||
const issue = new Refinement(ast, i, "From", ef); | ||
if (allErrors && AST.hasStableFilter(ast)) { | ||
return Option.match(ast.filter(i, options, ast), { | ||
onNone: () => Either.left(issue), | ||
onSome: ep => Either.left(new Composite(ast, i, [issue, new Refinement(ast, i, "Predicate", ep)])) | ||
}); | ||
} | ||
return Either.left(issue); | ||
}), a => Option.match(ast.filter(a, options, ast), { | ||
onNone: () => Either.right(a), | ||
onSome: ep => Either.left(new Refinement(ast, i, "Predicate", ep)) | ||
})); | ||
return handleForbidden(result, ast, i, options); | ||
}; | ||
} else { | ||
@@ -616,0 +630,0 @@ const from = goMemo(AST.typeAST(ast), true); |
@@ -181,2 +181,4 @@ /** | ||
const getStableFilterAnnotation = /*#__PURE__*/getAnnotation(StableFilterAnnotationId); | ||
/** @internal */ | ||
export const hasStableFilter = annotated => Option.exists(getStableFilterAnnotation(annotated), b => b === true); | ||
const JSONIdentifierAnnotationId = /*#__PURE__*/Symbol.for("@effect/schema/annotation/JSONIdentifier"); | ||
@@ -2098,7 +2100,4 @@ /** @internal */ | ||
} | ||
if (!isTransformation(ast.from)) { | ||
const annotations = getStableFilterAnnotation(ast); | ||
if (Option.isSome(annotations) && annotations.value === true) { | ||
return new Refinement(from, ast.filter); | ||
} | ||
if (!isTransformation(ast.from) && hasStableFilter(ast)) { | ||
return new Refinement(from, ast.filter); | ||
} | ||
@@ -2105,0 +2104,0 @@ } |
@@ -576,6 +576,20 @@ /** | ||
const from = goMemo(ast.from, true); | ||
return (i, options) => handleForbidden(flatMap(mapError(from(i, options), e => new Refinement(ast, i, "From", e)), a => Option.match(ast.filter(a, options ?? AST.defaultParseOption, ast), { | ||
onNone: () => Either.right(a), | ||
onSome: e => Either.left(new Refinement(ast, i, "Predicate", e)) | ||
})), ast, i, options); | ||
return (i, options) => { | ||
options = options ?? AST.defaultParseOption; | ||
const allErrors = options?.errors === "all"; | ||
const result = flatMap(orElse(from(i, options), ef => { | ||
const issue = new Refinement(ast, i, "From", ef); | ||
if (allErrors && AST.hasStableFilter(ast)) { | ||
return Option.match(ast.filter(i, options, ast), { | ||
onNone: () => Either.left(issue), | ||
onSome: ep => Either.left(new Composite(ast, i, [issue, new Refinement(ast, i, "Predicate", ep)])) | ||
}); | ||
} | ||
return Either.left(issue); | ||
}), a => Option.match(ast.filter(a, options, ast), { | ||
onNone: () => Either.right(a), | ||
onSome: ep => Either.left(new Refinement(ast, i, "Predicate", ep)) | ||
})); | ||
return handleForbidden(result, ast, i, options); | ||
}; | ||
} else { | ||
@@ -582,0 +596,0 @@ const from = goMemo(AST.typeAST(ast), true); |
{ | ||
"name": "@effect/schema", | ||
"version": "0.73.2", | ||
"version": "0.73.3", | ||
"description": "Modeling the schema of data structures as first-class values", | ||
@@ -5,0 +5,0 @@ "license": "MIT", |
@@ -811,19 +811,30 @@ /** | ||
const from = goMemo(ast.from, true) | ||
return (i, options) => | ||
handleForbidden( | ||
flatMap( | ||
mapError(from(i, options), (e) => new Refinement(ast, i, "From", e)), | ||
(a) => | ||
Option.match( | ||
ast.filter(a, options ?? AST.defaultParseOption, ast), | ||
return (i, options) => { | ||
options = options ?? AST.defaultParseOption | ||
const allErrors = options?.errors === "all" | ||
const result = flatMap( | ||
orElse(from(i, options), (ef) => { | ||
const issue = new Refinement(ast, i, "From", ef) | ||
if (allErrors && AST.hasStableFilter(ast)) { | ||
return Option.match( | ||
ast.filter(i, options, ast), | ||
{ | ||
onNone: () => Either.right(a), | ||
onSome: (e) => Either.left(new Refinement(ast, i, "Predicate", e)) | ||
onNone: () => Either.left<ParseIssue>(issue), | ||
onSome: (ep) => Either.left(new Composite(ast, i, [issue, new Refinement(ast, i, "Predicate", ep)])) | ||
} | ||
) | ||
), | ||
ast, | ||
i, | ||
options | ||
} | ||
return Either.left(issue) | ||
}), | ||
(a) => | ||
Option.match( | ||
ast.filter(a, options, ast), | ||
{ | ||
onNone: () => Either.right(a), | ||
onSome: (ep) => Either.left(new Refinement(ast, i, "Predicate", ep)) | ||
} | ||
) | ||
) | ||
return handleForbidden(result, ast, i, options) | ||
} | ||
} else { | ||
@@ -830,0 +841,0 @@ const from = goMemo(AST.typeAST(ast), true) |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
2311085
43054