[V3] Support template literals
See original GitHub issueHello 👋
I recently encountered a case, where my schema returned a string, but a function accept only a TS template string
Here is an example showing the issue: https://codesandbox.io/s/snowy-river-n2ih2?file=/src/index.ts
Is there a way, currently or in the future, to be able to do this:
const str = z.template(`${z.number()}.${z.number()}.${z.number()}`)
type Str = z.infer<typeof str>
// => Str: `${number}.${number}.${number}`
Issue Analytics
- State:
- Created 2 years ago
- Reactions:23
- Comments:14 (1 by maintainers)
Top Results From Across the Web
"template literals" | Can I use... Support tables for ... - CanIUse
Template literals are string literals allowing embedded expressions using backtick characters (`). You can use multi-line strings and string interpolation ...
Read more >Template literals (Template strings) - JavaScript | MDN
Template literals are literals delimited with backtick (`) characters, allowing for multi-line strings, string interpolation with embedded ...
Read more >8. Template literals - Exploring JS
Template literals are string literals with support for interpolation and multiple lines. Tagged template literals (short: tagged templates): are function calls ...
Read more >JavaScript Template Literals - W3Schools
Back-Tics Syntax · Quotes Inside Strings · Multiline Strings · Interpolation · Variable Substitutions · Expression Substitution · HTML Templates · Browser Support....
Read more >Documentation - Template Literal Types - TypeScript
When used with concrete literal types, a template literal produces a new string literal type by concatenating the contents. ts. type World =...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Good idea! I definitely want to support this eventually.
For now, you’ll have to implement this with
z.custom
:Stale Bot, no! We still care ❤️