> For the complete documentation index, see [llms.txt](https://racoon-js.gitbook.io/en/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://racoon-js.gitbook.io/en/other-common-api/errorforall.md).

# errorForAll

errorForAll(message, \[ctx])

Effect

`error` set the custom error message for the *restrict* before error calling position. `errorForAll` set custom error message for all *restrict*.

Since

\>=1.3.0

Arguments

* `message` `(string | function)` - The custom error message. If it's a function, the function should return a string, respect the custom error message. *The function has an argument: the original validate error object.*
* `[ctx]` ***(\*)*** - The execution context of `message` when it's a function.&#x20;

Example

```javascript
const schema = racoon
  .number()
  .error('error 1')
  .int()
  .min(2)
  .error('error 2')
  .max(5)
  .errorForAll('error for all');
  
schema.validate('abc'); // fail, error message: 'error 1'
schema.validate(3.2); // fail, error message: 'error for all'
schema.validate(1); // fail, error message: 'error 2'
schema.validate(6); // fail, error message: 'error for all'
```
