# Utilizing functions

## High-order validators

Consider writing a set of pure high-order validator functions that accept optional set of parameters and always return a validator function expected by React Advanced Form:

{% code title="validators/minLength.js" %}

```javascript
export default function minLength(length) {
    // returns a validator function expected by RAF
    return ({ value, fieldProps, form }) => {
        return value.length >= length
    }
}
```

{% endcode %}

Use the `minLength` function parametrically whenever necessary:

{% code title="validationRules.js" %}

```javascript
import minLength from './validators/minLength'

const validationRules = {
  type: {
    tel: {
      minLength: minLength(8),
    },
  },
  name: {
    firstName: {
      minLength: minLength(2),
    },
  },
}
```

{% endcode %}


---

# 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://redd.gitbook.io/react-advanced-form/recepies/reducing-boilerplate.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.
