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