File tree Expand file tree Collapse file tree 1 file changed +50
-0
lines changed Expand file tree Collapse file tree 1 file changed +50
-0
lines changed Original file line number Diff line number Diff line change @@ -194,6 +194,56 @@ SchemaInt32.prototype.cast = function(value) {
194194 }
195195} ;
196196
197+ /*!
198+ * ignore
199+ */
200+
201+ SchemaInt32 . $conditionalHandlers = {
202+ ...SchemaType . prototype . $conditionalHandlers ,
203+ $gt : handleSingle ,
204+ $gte : handleSingle ,
205+ $lt : handleSingle ,
206+ $lte : handleSingle
207+ } ;
208+
209+ /*!
210+ * ignore
211+ */
212+
213+ function handleSingle ( val , context ) {
214+ return this . castForQuery ( null , val , context ) ;
215+ }
216+
217+ /**
218+ * Casts contents for queries.
219+ *
220+ * @param {String } $conditional
221+ * @param {any } val
222+ * @api private
223+ */
224+
225+ SchemaInt32 . prototype . castForQuery = function ( $conditional , val , context ) {
226+ let handler ;
227+ if ( $conditional != null ) {
228+ handler = SchemaInt32 . $conditionalHandlers [ $conditional ] ;
229+
230+ if ( handler ) {
231+ return handler . call ( this , val ) ;
232+ }
233+
234+ return this . applySetters ( null , val , context ) ;
235+ }
236+
237+ try {
238+ return this . applySetters ( val , context ) ;
239+ } catch ( err ) {
240+ if ( err instanceof CastError && err . path === this . path && this . $fullPath != null ) {
241+ err . path = this . $fullPath ;
242+ }
243+ throw err ;
244+ }
245+ } ;
246+
197247
198248/*!
199249 * Module exports.
You can’t perform that action at this time.
0 commit comments