-
-
Notifications
You must be signed in to change notification settings - Fork 162
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Loosening restrictions on tuple types "Array contains Val" #1299
Comments
Also interestingly: // This will generate
export type InArray<TVal> =
| [TVal]
| [unknown, TVal]
| [TVal, unknown];
// This will fail with: TypeError: Cannot read properties of undefined (reading 'any')
export type InArray<TVal> =
| [TVal]
| [unknown, TVal]
| [TVal, unknown]
| [TVal, unknown, unknown]
| [unknown, TVal, unknown]
| [unknown, unknown, TVal]; |
I'm testing on it but error is not occured. Which value occurs the error? |
About the rest elements type in the first or middle position in the tuple, I haven't known the spec. By the way, I may need more investigation times because it is actually not possible in the JSON schema specification. If neccessary, I may prohibit the type due to the JSON schema reason. |
Thanks for the reply @samchon !! I really appreciate it ^_^ Here's the stacktrace/error for the above:
|
I have read through the docs before coming here, if I missed something important my apologies
Question
I need to validate a tuple type:
[Status]
where:Status
anywhere within the array regardless of it's index.Status
Essentially
Must contain a Status, anywhere
is the validation requirement. Which sounds deceptively simple, but is turning out to be rather difficult to actually get generated.I'm struggling to do this with
typia
:Status[]
is an arrya of onlyStatus
[...unknown[], Status]
is an array withStatus
as the last element[...unknown[], Status, ...unknown[]]
is an invalid type[...unknown[], Status] | [Status, ...unknown[]
['stuff', 'SUCCESS']
fails validationtuplePredicators
expect the array to be of length1
or2
only. And only expects aStatus
at[0]
?string[] | [Status]
is a valid type but results innonsensible intersection
Array<Status> & Array<unknown>
results innonsensible intersection
(This wouldn't make sense for typing anyways)How do I do this?
I do recognize the asinine-ness of this value, but... legacy system modeling
The text was updated successfully, but these errors were encountered: