# compose

It's the very backbone of **Deep Waters**, it takes a list of validators $$\[validators]$$ (*functions that accept a value and return a boolean*)  and returns a new function that takes a value $$v$$ and evaluates whether $$v$$ is valid for all the validators in $$\[validators]$$.

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

```javascript
import compose from './compose';
import isString from './isString';
import matchesPattern from './matchesPattern';

const isEmail = compose(
  isString,
  matchesPattern(/^\w+([.-]?\w+)*@\w+([.-]?\w+)*(\.\w{2,3})+$/),
);

export default isEmail;
```

{% endcode %}

{% hint style="info" %}
Please note, **compose** removes all the duplicate validators
{% endhint %}

#### Related validators

{% content-ref url="/pages/-M6UnSCICpEyxZ9lypv8" %}
[when](/deep-waters/composition/when.md)
{% endcontent-ref %}

{% content-ref url="/pages/-M6UnXFlU6IeRdIBsRG0" %}
[or](/deep-waters/composition/or.md)
{% endcontent-ref %}

{% content-ref url="/pages/-M6UnanTnzxPY5GLxnUW" %}
[not](/deep-waters/composition/not.md)
{% endcontent-ref %}


---

# 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://antonioru.gitbook.io/deep-waters/composition/compose.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.
