Empty string or number
I have this type that I want to reuse:
I want to reuse it so if the string is empty, leave it as is, otherwise parse it as the
number
type.
But when I do this, it complains:
This works though, so it's no big deal but just curious if it's possible to combine these above?
10 Replies
I also have a currency type that I may want to apply the same logic to:
But same problem there.
It could be solved in the pipe function, but it would be nice to just be able to add an empty string type to another type, to avoid rewriting functions.
why not apply the number type through another pipe?
ie:
if you want you could put the code adding the pipe into a function and use that instead
That works, but I'd like to be able, if possible, to use a type directly so it can be easily chained to existing types
The key is
with overlapping input
. You just have to make sure if one branch of the union contains a transform, we can tell they have no overlap:
In this case I don't think the pipe would ever apply, but hopefully that concept is helpful
Or rather, the pipe would never do anything since s
will always be truthyMakes sense, thank you!
Just started up a Deno project and used Arktype for CSV -> object validation, so incredibly convenient. Thank you again βΊοΈ
Glad it's been going well! Still have so much I want to build + document
Yeah, I'd love to use the JSON Schema feature to improve the adapter for Superforms
Close on that one and I'm really happy with the API

Basically you can handle each incompatibility individually or apply a fallback to all of them at once
Ohh, great
Looking forward to that one!