Preset Filters
Filter Sphere provides a collection of preset filter functions that cover common filtering scenarios. These functions are designed to work with various data types including strings, numbers, dates, arrays, and enums.
Available Filters
Section titled “Available Filters”The following table shows all available preset filters and their type signatures:
| ID | Filter Name | Signature | Type |
|---|---|---|---|
| equals | equals | (T, T) => boolean | Generic |
| notEqual | not equal | (T, T) => boolean | Generic |
| enumEquals | equals | (T, T) => boolean | Generic |
| enumNotEqual | not equal | (T, T) => boolean | Generic |
| isEmpty | is empty | (T) => boolean | Generic |
| isNotEmpty | is not empty | (T) => boolean | Generic |
| contains | contains | (T, array) => boolean | Generic |
| notContains | not contains | (T, array) => boolean | Generic |
| startsWith | starts with | (string, string) => boolean | Typed |
| endsWith | ends with | (string, string) => boolean | Typed |
| greaterThan | > | (number, number) => boolean | Typed |
| greaterThanOrEqual | >= | (number, number) => boolean | Typed |
| lessThan | < | (number, number) => boolean | Typed |
| lessThanOrEqual | <= | (number, number) => boolean | Typed |
| before | before | (date, date) => boolean | Typed |
| after | after | (date, date) => boolean | Typed |
Filter Categories
Section titled “Filter Categories”Equality Filters
Section titled “Equality Filters”- Equals: Compare values for equality (case-insensitive for strings)
- Not Equal: Compare values for inequality (case-insensitive for strings)
- Enum Equals: Strict equality for enum values
- Enum Not Equal: Strict inequality for enum values
String Filters
Section titled “String Filters”- Contains: Check if a string contains a substring (case-insensitive)
- Not Contains: Check if a string does not contain a substring (case-insensitive)
- Starts With: Check if a string starts with a prefix (case-insensitive)
- Ends With: Check if a string ends with a suffix (case-insensitive)
Number Filters
Section titled “Number Filters”- Greater Than: Check if a number is greater than another
- Greater Than Or Equal: Check if a number is greater than or equal to another
- Less Than: Check if a number is less than another
- Less Than Or Equal: Check if a number is less than or equal to another
Date Filters
Section titled “Date Filters”- Before: Check if a date is before another date
- After: Check if a date is after another date
Empty/Null Filters
Section titled “Empty/Null Filters”- Is Empty: Check if a value is null, undefined, or empty string
- Is Not Empty: Check if a value is not null, undefined, or empty string
Array Filters
Section titled “Array Filters”- Contains: Check if an array contains an element
- Not Contains: Check if an array does not contain an element
Import preset filters in your application:
import { presetFilter } from "@fn-sphere/filter";These filters can be used with the Filter Sphere system to build dynamic filtering interfaces.