Skip to content

Commit

Permalink
fix(validator): reset boolean transform logic
Browse files Browse the repository at this point in the history
  • Loading branch information
NWYLZW committed Feb 21, 2024
1 parent d428890 commit d3c2482
Showing 1 changed file with 32 additions and 10 deletions.
42 changes: 32 additions & 10 deletions packages/validator/src/types/primitive.boolean.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { IsEqual, Switch, t as tn } from '@typp/core'
import type { IsEqual, IsIntersect, Switch, t as tn } from '@typp/core'

import { FALSY } from '../base'
import { preprocess } from '../utils.inner'
Expand All @@ -16,24 +16,46 @@ declare module '@typp/core' {
[T] extends [boolean] ? true : false,
Switch<{
any: [IsEqual<Input, any>, unknown]
bigint: [
[Input] extends [bigint] ? true : false,
boolean
boolean: [
true extends (
| IsIntersect<Input, true>
| IsIntersect<Input, false>
| IsIntersect<Input, Boolean>
) ? true : false,
[InputRest] extends [never] ? (
Input extends infer UnionInputItem ? (
IsEqual<UnionInputItem, Boolean> extends true
? boolean
: Extract<UnionInputItem, boolean>
) : never
) : never
]
self: [
[Input] extends [boolean] ? true : false,
bigint: [
true extends (
| IsIntersect<InputRest, bigint>
| IsIntersect<InputRest, BigInt>
) ? true : false,
boolean
]
number: [
[Input] extends [number] ? true : false,
true extends (
| IsIntersect<InputRest, number>
| IsIntersect<InputRest, Number>
) ? true : false,
boolean
]
string: [
[Input] extends [string] ? true : false,
boolean,
true extends (
| IsIntersect<InputRest, string>
| IsIntersect<InputRest, String>
) ? true : false,
boolean
]
nullOrUndefined: [
[Input] extends [null | undefined] ? true : false,
true extends (
| IsIntersect<InputRest, null>
| IsIntersect<InputRest, undefined>
) ? true : false,
false
]
}>
Expand Down

0 comments on commit d3c2482

Please sign in to comment.