Comments (1)
Thanks for reporting this issue. It seems that TypeScript is not able to detect the default value as it should. I will investigate this. Another workaround is to add as const
to the literal value.
import * as v from 'valibot';
const RawDefaultSchema = v.optional(
v.object({ type: v.literal('1'), x: v.number() }),
{ type: '1' as const, x: 1 } // <--
);
type RawDefault = v.Output<typeof RawDefaultSchema>;
from valibot.
Related Issues (20)
- [i18n] equal is still present in translations HOT 1
- Playground UI/UX HOT 1
- Cannot use `variant` together with `merge` HOT 1
- Union of literals HOT 1
- Add passthrough object schema HOT 3
- Omit removes rest object props HOT 12
- Ability to extend existing declared schemas without redefining HOT 4
- TS error when using custom() HOT 9
- How do I derive a schema with more validations/transformations? HOT 1
- Allow errorMap (like zod) message for literal HOT 11
- `intersect` of `object` and `record` does not work like Typescript HOT 9
- using `union` as key of `record` adds `undefined` to the value type HOT 13
- `isoTimestamp` only accepts UTC timestamps HOT 3
- Not able to validate file uploads on the backend, even though it works on the frontend HOT 4
- Search fails to work HOT 1
- Timestamp regex doesn't support timezone other than Zulu HOT 1
- Can't use Valibot with H3 Data validation HOT 6
- optional string field with string min/max options set wrong meta in veevalidate HOT 2
- How to conditionally require object with all its fields HOT 2
- `<select>` custom validation inside a `variant` schema HOT 4
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 valibot.