@@ -25,7 +25,7 @@ export function object<ParsedKeys extends string, T extends PropertySchemas<Pars
2525 const baseSchema : BaseObjectSchema < inferRawObjectFromPropertySchemas < T > , inferParsedObjectFromPropertySchemas < T > > = {
2626 ...OBJECT_LIKE_BRAND ,
2727
28- parse : ( raw , { skipUnknownKeysOnParse = false } = { } ) => {
28+ parse : async ( raw , { skipUnknownKeysOnParse = false } = { } ) => {
2929 const rawKeyToProperty : Record < string , ObjectPropertyWithRawKey > = { } ;
3030
3131 for ( const [ parsedKey , schemaOrObjectProperty ] of entries ( schemas ) ) {
@@ -46,7 +46,7 @@ export function object<ParsedKeys extends string, T extends PropertySchemas<Pars
4646 const property = rawKeyToProperty [ rawKey ] ;
4747
4848 if ( property != null ) {
49- const value = property . valueSchema . parse ( rawPropertyValue ) ;
49+ const value = await property . valueSchema . parse ( rawPropertyValue ) ;
5050 parsed [ property . parsedKey ] = value ;
5151 } else if ( ! skipUnknownKeysOnParse && rawPropertyValue != null ) {
5252 parsed [ rawKey ] = rawPropertyValue ;
@@ -56,18 +56,18 @@ export function object<ParsedKeys extends string, T extends PropertySchemas<Pars
5656 return parsed as inferParsedObjectFromPropertySchemas < T > ;
5757 } ,
5858
59- json : ( parsed , { includeUnknownKeysOnJson = false } = { } ) => {
59+ json : async ( parsed , { includeUnknownKeysOnJson = false } = { } ) => {
6060 const raw : Record < string | number | symbol , any > = { } ;
6161
6262 for ( const [ parsedKey , parsedPropertyValue ] of entries ( parsed ) ) {
6363 const schemaOrObjectProperty = schemas [ parsedKey as keyof T ] ;
6464 // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
6565 if ( schemaOrObjectProperty != null ) {
6666 if ( isProperty ( schemaOrObjectProperty ) ) {
67- const value = schemaOrObjectProperty . valueSchema . json ( parsedPropertyValue ) ;
67+ const value = await schemaOrObjectProperty . valueSchema . json ( parsedPropertyValue ) ;
6868 raw [ schemaOrObjectProperty . rawKey ] = value ;
6969 } else {
70- const value = schemaOrObjectProperty . json ( parsedPropertyValue ) ;
70+ const value = await schemaOrObjectProperty . json ( parsedPropertyValue ) ;
7171 raw [ parsedKey ] = value ;
7272 }
7373 } else if ( includeUnknownKeysOnJson && parsedPropertyValue != null ) {
@@ -92,13 +92,13 @@ export function getObjectUtils<Raw, Parsed>(schema: BaseObjectSchema<Raw, Parsed
9292 extend : < RawExtension , ParsedExtension > ( extension : ObjectSchema < RawExtension , ParsedExtension > ) => {
9393 const baseSchema : BaseObjectSchema < Raw & RawExtension , Parsed & ParsedExtension > = {
9494 ...OBJECT_LIKE_BRAND ,
95- parse : ( raw , opts ) => ( {
96- ...schema . parse ( raw , opts ) ,
97- ...extension . parse ( raw , opts ) ,
95+ parse : async ( raw , opts ) => ( {
96+ ...( await schema . parse ( raw , opts ) ) ,
97+ ...( await extension . parse ( raw , opts ) ) ,
9898 } ) ,
99- json : ( parsed , opts ) => ( {
100- ...schema . json ( parsed , opts ) ,
101- ...extension . json ( parsed , opts ) ,
99+ json : async ( parsed , opts ) => ( {
100+ ...( await schema . json ( parsed , opts ) ) ,
101+ ...( await extension . json ( parsed , opts ) ) ,
102102 } ) ,
103103 } ;
104104
0 commit comments