# FilterInput

The `Xmf\FilterInput` class support cleaning and filtering data

## FilterInput::getInstance()

Returns a `Xmf\FilterInput` object, only creating it if it does not already exist.

It is possible to customize the behavior of FilterInput by passing configuration variables to getInstance(). See the source for more information.

## process(*$source*)

Clean the *$source*, a string or array of values, processing to remove XSS and other *bad* code.

Returns the *cleaned* version of *$source*.

## FilterInput::clean(*$source*, *$type*)

Cleans the input *$source* removing XSS and other *bad* code using the defaults. Also, filters the input, conforming to the specified *$type*. 'STRING' is the default *$type*.

Available type are the same as documented with the cleanVar() method.

## cleanVar(*$source*, *$type*)

Cleans the input *$source* with rules established when the instance of FilterInput was instantiated. Also, filters the input, conforming it to the specified *$type*. 'STRING' is the default *$type*.

Available type are:

| Type              | Allowed value                                                                          |
| ----------------- | -------------------------------------------------------------------------------------- |
| ALPHANUM or ALNUM | Alphanumeric                                                                           |
| ARRAY             | Recursively cleans each element                                                        |
| BASE64            | Base64 encoded                                                                         |
| BOOLEAN or BOOL   | true or false                                                                          |
| CMD               | Command - only characters A-Z, 0-9, underscore, dash and period, forced to lower case. |
| EMAIL             | a valid email address                                                                  |
| FLOAT or DOUBLE   | floating point number                                                                  |
| INTEGER or INT    | an integer                                                                             |
| IP                | a valid IP address                                                                     |
| PATH              | a filesystem or web path                                                               |
| STRING            | a string                                                                               |
| USERNAME          | Username                                                                               |
| WEBURL            | a web URL                                                                              |
| WORD              | only letters A-Z and underscore                                                        |

Returns the *cleaned* version of *$source*.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://xoops.gitbook.io/xmf-cookbook/reference/filterinput.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
