File tree Expand file tree Collapse file tree 2 files changed +22
-4
lines changed
Expand file tree Collapse file tree 2 files changed +22
-4
lines changed Original file line number Diff line number Diff line change @@ -27,7 +27,8 @@ import type {
2727 InputSchema ,
2828 MaybeArray ,
2929 StandaloneInputSchema ,
30- StandardSchemaV1LikeValidate
30+ StandardSchemaV1LikeValidate ,
31+ UnwrapSchema
3132} from './types'
3233
3334import type { StandardSchemaV1Like } from './types'
@@ -40,10 +41,10 @@ export interface ElysiaTypeCheck<T extends TSchema>
4041 provider : 'typebox' | 'standard'
4142 schema : T
4243 config : Object
43- Clean ?( v : unknown ) : T
44- parse ( v : unknown ) : T
44+ Clean ?( v : unknown ) : UnwrapSchema < T >
45+ parse ( v : unknown ) : UnwrapSchema < T >
4546 safeParse ( v : unknown ) :
46- | { success : true ; data : T ; error : null }
47+ | { success : true ; data : UnwrapSchema < T > ; error : null }
4748 | {
4849 success : false
4950 data : null
Original file line number Diff line number Diff line change 1+ import { t , getSchemaValidator } from '../../src'
2+ import { expectTypeOf } from 'expect-type'
3+
4+ // schema validator
5+ {
6+ const schema = t . Object ( {
7+ id : t . Number ( ) ,
8+ name : t . String ( )
9+ } )
10+
11+ const validator = getSchemaValidator ( schema )
12+ const result = validator . safeParse ( { id : 1 , name : 'test' } )
13+
14+ if ( result . success ) {
15+ expectTypeOf ( result . data ) . toEqualTypeOf < { id : number ; name : string } > ( )
16+ }
17+ }
You can’t perform that action at this time.
0 commit comments