diff --git a/lib/helpers.js b/lib/helpers.js index 1ade979..cf38a8d 100644 --- a/lib/helpers.js +++ b/lib/helpers.js @@ -353,6 +353,20 @@ function attachQueries (request) { request.options.range[field][index] = castValue(query[parameter], fieldType, options) } + else if (filterType === 'fuzzy-match'){ + + if ( ! fields[field].type ){ + throw new BadRequestError( `fuzzy-match only allowed on attributes.` ) + } + + if ( fields[field].type.name !== "String"){ + throw new BadRequestError( + `fuzzy-match only allowed on String types. ${field} is of type ${fields[field].type.name }` ) + } + + if (!('fuzzyMatch' in request.options)) request.options['fuzzyMatch'] = {} + request.options.fuzzyMatch[field] = query[parameter] + } else throw new BadRequestError( `The filter "${filterType}" is not valid.`) }