You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
exportconstupdateUserValidator=vine.withMetaData<{other: User}>().compile(vine.object({email: vine.string().email().optional(),password: vine.string().minLength(6).optional(),role: vine.string().in(['admin','user']).optional(),maxStreams: vine.number().min(0).withoutDecimals().optional().transform(async(value,field)=>{constall=`user:${field.meta.other.id}:streams:*`conststreams=awaitredis.keys(all)if(streams.length>value){thrownewError('Cannot set max streams to a value lower than the current number of streams')}returnvalue}),}))
After validation i got:
constpayload=awaitupdateUserValidator.validate(ctx.request.all(),{meta: { other }})// With the following typeconstpayload: {email: string|undefined;password: string|undefined;role: string|undefined;maxStreams: Promise<number>;}
The thing is, i want the 'maxStreams' to be a number, not a Promise<number>, how could i do that without awaiting payload.maxStreams?
Any ideas?
Problably something like Field.awaited() would be cool
Example usage:
maxStreams: vine.number().min(0).withoutDecimals().optional().transform(async(value,field)=>{constall=`user:${field.meta.other.id}:streams:*`conststreams=awaitredis.keys(all)if(streams.length>value){thrownewError('Cannot set max streams to a value lower than the current number of streams')}returnvalue}).awaited()
The text was updated successfully, but these errors were encountered:
I have the following code:
After validation i got:
The thing is, i want the 'maxStreams' to be a
number
, not aPromise<number>
, how could i do that without awaitingpayload.maxStreams
?Any ideas?
Problably something like
Field.awaited()
would be coolExample usage:
The text was updated successfully, but these errors were encountered: