> For the complete documentation index, see [llms.txt](https://redd.gitbook.io/react-advanced-form/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://redd.gitbook.io/react-advanced-form/recepies/reducing-boilerplate.md).

# 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 %}
