---
lang: en
title: 'API docs: repository.constrainfilter'
keywords: LoopBack 4.0, LoopBack 4, Node.js, TypeScript, OpenAPI
sidebar: lb4_sidebar
editurl: https://github.com/strongloop/loopback-next/tree/master/packages/repository
permalink: /doc/en/lb4/apidocs.repository.constrainfilter.html
---

<!-- Do not edit this file. It is automatically generated by API Documenter. -->

[Home](./index.md) &gt; [@loopback/repository](./repository.md) &gt; [constrainFilter](./repository.constrainfilter.md)

## constrainFilter() function

A utility function which takes a filter and enforces constraint(s) on it

<b>Signature:</b>

```typescript
export declare function constrainFilter<T extends object>(originalFilter: Filter<T> | undefined, constraint: AnyObject): Filter<T>;
```

## Parameters

|  Parameter | Type | Description |
|  --- | --- | --- |
|  originalFilter | [Filter](./filter.filter.md)<!-- -->&lt;T&gt; \| undefined | the filter to apply the constrain(s) to |
|  constraint | [AnyObject](./repository.anyobject.md) | the constraint which is to be applied on the filter |

<b>Returns:</b>

[Filter](./filter.filter.md)<!-- -->&lt;T&gt;

Filter the modified filter with the constraint, otherwise the original filter


