Comments (1)
This also appears to affect Unions as well, following on from your example:
// Discriminated Union example
const A = Type.Object({
a: Type.String(),
b: Type.Optional(Type.Never()),
c: Type.Number()
});
const B = Type.Object({
a: Type.Optional(Type.Never()),
b: Type.String(),
c: Type.Number()
});
const C = Type.Union([A, B]);
In version 0.30
, running Value.Errors
on A
, B
and C
gives the following:
# Value.Errors(A, {})
> /a: Expected string
> /c: Expected number
> /a: Expected required property
> /c: Expected required property
# Value.Errors(B, {})
> /b: Expected string
> /c: Expected number
> /b: Expected required property
> /c: Expected required property
# Value.Errors(C, {})
> : Expected value of union
> /a: Expected string
> /c: Expected number
> /a: Expected required property
> /c: Expected required property
> /b: Expected string
> /c: Expected number
> /b: Expected required property
> /c: Expected required property
In version 0.31
onwards, it instead gives the following output where the errors are no longer propagating:
# Value.Errors(A, {})
> /a: Required property
> /c: Required property
> /a: Expected string
> /c: Expected number
# Value.Errors(B, {})
> /b: Required property
> /c: Required property
> /b: Expected string
> /c: Expected number
# Value.Errors(C, {})
> : Expected union value
from typebox.
Related Issues (20)
- Should `IsValueType` guard consider `Date`? HOT 1
- ESNext target HOT 3
- Trying to do codegen from Drizzle schemas HOT 1
- Make `default` and `examples` schema options properties type-safe HOT 2
- Indicate which files don't have "sideEffects" in package.json for improved tree shaking HOT 3
- Type.String().Optional() is accepted on ts-hint / ts-lint, and even build successfully; but of course, "Optional()" does not exists HOT 2
- Dynamic Template Literals can't be Mapped HOT 2
- How should TypeBox types be used with TS type predicates? HOT 2
- TypeCompiler.Compile incorrectly parsing `Record<any, any>`
- Error when using Composite with Ref (Unable to dereference schema with $id 'undefined') HOT 3
- Transform type keys in Record HOT 2
- Is it possible to add support to the Type.String additional properties for the enum keyword HOT 2
- Support for async validations? HOT 1
- Transform + Map/Index does not work HOT 4
- Update the error message for required properties
- Covariance issue with `TypeCheck<TSchema>` and `TypeCheck<TObject<{}>>`
- Default values in nested objects are not generated HOT 1
- Doubt on Record HOT 2
- TypeCompiler compile on Type.Strict(T) - Preflight validation check failed to guard for the given schema
- Max call stack size exceeded
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from typebox.