@effect/schema
Advanced tools
Comparing version 0.0.0-snapshot-b4323ccacbf56b5c574bb69e7775d11cb8d2178a to 0.0.0-snapshot-b823490622aaa8337bc7047aba37354de498625b
@@ -459,12 +459,12 @@ "use strict"; | ||
/** @internal */ | ||
const mergeParseOptions = (a, b) => { | ||
if (a === undefined) { | ||
return b; | ||
const mergeParseOptions = (options, overrideOptions) => { | ||
if (overrideOptions === undefined || Predicate.isNumber(overrideOptions)) { | ||
return options; | ||
} | ||
if (b === undefined) { | ||
return a; | ||
if (options === undefined) { | ||
return overrideOptions; | ||
} | ||
const out = {}; | ||
out.errors = b.errors ?? a.errors; | ||
out.onExcessProperty = b.onExcessProperty ?? a.onExcessProperty; | ||
out.errors = overrideOptions.errors ?? options.errors; | ||
out.onExcessProperty = overrideOptions.onExcessProperty ?? options.onExcessProperty; | ||
return out; | ||
@@ -471,0 +471,0 @@ }; |
@@ -463,3 +463,3 @@ /** | ||
*/ | ||
export declare const is: <A, I, R>(schema: Schema.Schema<A, I, R>, options?: AST.ParseOptions) => (u: unknown, overrideOptions?: AST.ParseOptions) => u is A; | ||
export declare const is: <A, I, R>(schema: Schema.Schema<A, I, R>, options?: AST.ParseOptions) => (u: unknown, overrideOptions?: AST.ParseOptions | number) => u is A; | ||
/** | ||
@@ -466,0 +466,0 @@ * @category validation |
@@ -1719,2 +1719,9 @@ /** | ||
break; | ||
case "Enums": | ||
{ | ||
for (const [_, name] of key.enums) { | ||
propertySignatures.push(new PropertySignature(name, value, false, true)); | ||
} | ||
break; | ||
} | ||
case "UniqueSymbol": | ||
@@ -1759,3 +1766,3 @@ propertySignatures.push(new PropertySignature(key.symbol, value, false, true)); | ||
} | ||
return new Transformation(pick(ast.from, fromKeys), pick(ast.to, keys), Arr.isNonEmptyReadonlyArray(ts) ? new TypeLiteralTransformation(ts) : composeTransformation); | ||
return Arr.isNonEmptyReadonlyArray(ts) ? new Transformation(pick(ast.from, fromKeys), pick(ast.to, keys), new TypeLiteralTransformation(ts)) : pick(ast.from, fromKeys); | ||
} | ||
@@ -1889,6 +1896,2 @@ case "FinalTransformation": | ||
}; | ||
/** @internal */ | ||
export const getToPropertySignatures = ps => ps.map(p => new PropertySignature(p.name, typeAST(p.type), p.isOptional, p.isReadonly, p.annotations)); | ||
/** @internal */ | ||
export const getToIndexSignatures = ps => ps.map(is => new IndexSignature(is.parameter, typeAST(is.type), is.isReadonly)); | ||
/** | ||
@@ -1895,0 +1898,0 @@ * @since 1.0.0 |
@@ -417,12 +417,12 @@ /** | ||
/** @internal */ | ||
export const mergeParseOptions = (a, b) => { | ||
if (a === undefined) { | ||
return b; | ||
export const mergeParseOptions = (options, overrideOptions) => { | ||
if (overrideOptions === undefined || Predicate.isNumber(overrideOptions)) { | ||
return options; | ||
} | ||
if (b === undefined) { | ||
return a; | ||
if (options === undefined) { | ||
return overrideOptions; | ||
} | ||
const out = {}; | ||
out.errors = b.errors ?? a.errors; | ||
out.onExcessProperty = b.onExcessProperty ?? a.onExcessProperty; | ||
out.errors = overrideOptions.errors ?? options.errors; | ||
out.onExcessProperty = overrideOptions.onExcessProperty ?? options.onExcessProperty; | ||
return out; | ||
@@ -429,0 +429,0 @@ }; |
{ | ||
"name": "@effect/schema", | ||
"version": "0.0.0-snapshot-b4323ccacbf56b5c574bb69e7775d11cb8d2178a", | ||
"version": "0.0.0-snapshot-b823490622aaa8337bc7047aba37354de498625b", | ||
"description": "Modeling the schema of data structures as first-class values", | ||
@@ -16,3 +16,3 @@ "license": "MIT", | ||
"peerDependencies": { | ||
"effect": "^0.0.0-snapshot-b4323ccacbf56b5c574bb69e7775d11cb8d2178a" | ||
"effect": "^0.0.0-snapshot-b823490622aaa8337bc7047aba37354de498625b" | ||
}, | ||
@@ -19,0 +19,0 @@ "publishConfig": { |
@@ -474,14 +474,14 @@ /** | ||
export const mergeParseOptions = ( | ||
a: AST.ParseOptions | undefined, | ||
b: AST.ParseOptions | undefined | ||
options: AST.ParseOptions | undefined, | ||
overrideOptions: AST.ParseOptions | number | undefined | ||
): AST.ParseOptions | undefined => { | ||
if (a === undefined) { | ||
return b | ||
if (overrideOptions === undefined || Predicate.isNumber(overrideOptions)) { | ||
return options | ||
} | ||
if (b === undefined) { | ||
return a | ||
if (options === undefined) { | ||
return overrideOptions | ||
} | ||
const out: Mutable<AST.ParseOptions> = {} | ||
out.errors = b.errors ?? a.errors | ||
out.onExcessProperty = b.onExcessProperty ?? a.onExcessProperty | ||
out.errors = overrideOptions.errors ?? options.errors | ||
out.onExcessProperty = overrideOptions.onExcessProperty ?? options.onExcessProperty | ||
return out | ||
@@ -719,3 +719,3 @@ } | ||
const parser = goMemo(AST.typeAST(schema.ast), true) | ||
return (u: unknown, overrideOptions?: AST.ParseOptions): u is A => | ||
return (u: unknown, overrideOptions?: AST.ParseOptions | number): u is A => | ||
Either.isRight(parser(u, { ...mergeParseOptions(options, overrideOptions), isExact: true }) as any) | ||
@@ -722,0 +722,0 @@ } |
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 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 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 too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
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
2329790
39903
8081