TizzySaurus
Aarktype
•Created by rostero on 4/18/2025 in #questions
How to ensure comma delimited set of numbers or fallback to undefined?
or w/e
20 replies
Aarktype
•Created by rostero on 4/18/2025 in #questions
How to ensure comma delimited set of numbers or fallback to undefined?
You can implement custom logic like this with a pipe (morph): https://arktype.io/docs/intro/morphs-and-more
20 replies
Aarktype
•Created by LORENS on 4/17/2025 in #questions
onUndeclaredKey()
In fact since you're reusing the trimmed non-empty string I'd probably just store that as it's own type.
4 replies
Aarktype
•Created by LORENS on 4/17/2025 in #questions
onUndeclaredKey()
Fwiw the whole point of
.to()
is that you don't need the nested type()
call. If you have it to get the .describe()
you can use tuple syntax (iirc something like ["string > 0", "@", {description: "Not empty"}]
).
And description: type("string | null").optional()
can be made more efficient by doing "description?": "string | null"
(again, removing an unnecessary nested type()
call)4 replies
Aarktype
•Created by Tehrin on 4/11/2025 in #questions
Type.any but with specific scope?
Yeah, it should still be the entire type
19 replies
Aarktype
•Created by Tehrin on 4/11/2025 in #questions
Type.any but with specific scope?
I think I see what you mean now actually
19 replies
Aarktype
•Created by Tehrin on 4/11/2025 in #questions
Type.any but with specific scope?
You need
T
to be the entire ArkType type, not just the "runtime" type (i.e. Type<number>
and not number
),19 replies
Aarktype
•Created by Tehrin on 4/11/2025 in #questions
Type.any but with specific scope?
It's impossible for it to use
T["infer"]
because your T
isn't the ArkType type lol19 replies
Aarktype
•Created by Tehrin on 4/11/2025 in #questions
Type.any but with specific scope?
Because
T["Infer"]
will handle pipes, defaults, etc.19 replies
Aarktype
•Created by Tehrin on 4/11/2025 in #questions
Type.any but with specific scope?
What you likely want is
19 replies
Aarktype
•Created by Tehrin on 4/11/2025 in #questions
Type.any but with specific scope?
Yeah, you shouldn't use
T
in the return for this very reason19 replies
Aarktype
•Created by Tehrin on 4/11/2025 in #questions
Type.any but with specific scope?
Right... So do
foo<T>(x: Type<T, MyScope>)
then?19 replies
Aarktype
•Created by Tehrin on 4/11/2025 in #questions
Type.any but with specific scope?
Well
type.Any
doesn't know the T either... that's the point of it19 replies
Aarktype
•Created by Tehrin on 4/11/2025 in #questions
Type.any but with specific scope?
Type<unknown, MyScope>
19 replies
Aarktype
•Created by log1st on 4/6/2025 in #questions
Resolving type and its nodes
type.expression
is just a human readable version of it, but isn't as good for introspectability4 replies
Aarktype
•Created by log1st on 4/6/2025 in #questions
Resolving type and its nodes
type.json
is arguably better here since that's the actual internal ArkType schema4 replies
Aarktype
•Created by TaQuanMinhLong on 4/2/2025 in #questions
Loose string schema
But yeah, it's likely TS just reduces it
20 replies
Aarktype
•Created by TaQuanMinhLong on 4/2/2025 in #questions
Loose string schema
Sorry, I meant
type.or(xxx, yyy, zzz, aaa)
20 replies
Aarktype
•Created by TaQuanMinhLong on 4/2/2025 in #questions
Loose string schema
Have you tried
type.enum("'literal'", "'or'", "'any'", "string")
?20 replies
Aarktype
•Created by TaQuanMinhLong on 4/2/2025 in #questions
Loose string schema
Bold of you to assume I've got access to my PC (I don't) :)
20 replies