@@ -252,4 +252,49 @@ describe('@feathersjs/schema/schema', () => {
252252
253253 assert . deepStrictEqual ( res , { x : 3 } ) ;
254254 } ) ;
255+
256+ it ( 'can handle compound queryProperty' , async ( ) => {
257+ const formatsSchema = schema ( {
258+ $id : 'compoundQueryProperty' ,
259+ type : 'object' ,
260+ required : [ ] ,
261+ additionalProperties : false ,
262+ properties : {
263+ dobString : queryProperty ( {
264+ oneOf : [
265+ { type : 'string' , format : 'date' , convert : true } ,
266+ { type : 'string' , format : 'date-time' , convert : true } ,
267+ { type : 'object' }
268+ ]
269+ } )
270+ }
271+ } as const , customAjv ) ;
272+
273+ const validated = await formatsSchema . validate ( {
274+ dobString : { $gt : '2025-04-25' , $lte : new Date ( '2027-04-25' ) }
275+ } ) ;
276+
277+ assert . ok ( validated )
278+ } ) ;
279+
280+ it ( 'can still fail queryProperty validation' , async ( ) => {
281+ const formatsSchema = schema ( {
282+ $id : 'compoundQueryPropertyFail' ,
283+ type : 'object' ,
284+ required : [ ] ,
285+ additionalProperties : false ,
286+ properties : {
287+ dobString : queryProperty ( { type : 'string' } )
288+ }
289+ } as const , customAjv ) ;
290+
291+ try {
292+ const validated = await formatsSchema . validate ( {
293+ dobString : { $moose : 'test' }
294+ } ) ;
295+ assert ( ! validated , 'should not have gotten here' )
296+ } catch ( error : any ) {
297+ assert . ok ( error . data ?. length > 0 )
298+ }
299+ } ) ;
255300} ) ;
0 commit comments