`string.integer.parsed` with limits

I need a simple port number, 1 < integer < 9999 Hovewer, I want to parse it from env string so I need string.integer.parse How do I make the limited parsed integer?
26 Replies
Dimava
Dimava2w ago
import { type } from 'arktype'
const oneTo9999 = type('1 <= number.integer <= 9999')

const T = type({
PORT: ['string.integer.parse', '=>', oneTo9999],
})
const defaults: typeof T.in = {
PORT: 123,
}
import { type } from 'arktype'
const oneTo9999 = type('1 <= number.integer <= 9999')

const T = type({
PORT: ['string.integer.parse', '=>', oneTo9999],
})
const defaults: typeof T.in = {
PORT: 123,
}
(this doesn't work) WIW is
const T = type({
PORT: '1 < string.integer.parse < 9999 | 1 < integer < 9999'
})
const tIn: typeof T.in
const tLike = T.typedAssert({
PORT: 1234
})
const T = type({
PORT: '1 < string.integer.parse < 9999 | 1 < integer < 9999'
})
const tIn: typeof T.in
const tLike = T.typedAssert({
PORT: 1234
})
ssalbdivad
ssalbdivad2w ago
So what is your issue?
No description
ssalbdivad
ssalbdivad2w ago
t.in is a Type, not an inferred output It's t.infer like it has always been
Dimava
Dimava2w ago
🤔 what was my issue again
Dimava
Dimava2w ago
This
No description
Dimava
Dimava2w ago
2.0.0-rc.6
ssalbdivad
ssalbdivad2w ago
what is the error on T? Oh just that it's unused?
Dimava
Dimava2w ago
..... Waitaminute Lemme unupdate back
ssalbdivad
ssalbdivad2w ago
I can't repro it
Dimava
Dimava2w ago
I can't repron't it Researching...
ssalbdivad
ssalbdivad2w ago
I mean that type doesn't make any sense it's like it's not even trying to infer anything
Dimava
Dimava2w ago
Okay this was tsconfig looking what exactly
ssalbdivad
ssalbdivad2w ago
I have tested it with only strictNullChecks in tsconfig and it works So I guess you have some resolution setting that is actively breaking it
Dimava
Dimava2w ago
Okay it was "moduleResolution": "node",
ssalbdivad
ssalbdivad2w ago
But that should work I thought? Isn't that the default I know there was a problem with node resolution in a previous build so I added tests for default settings and people said their node resolution was fixed
Want results from more Discord servers?
Add your server