# Checking for Duplicate values in a field

To prevent users from uploading duplicate values for a specific field, you can utilize the [data validation function](/developer-docs/uploader-client-side-validation/validation-functions.md).&#x20;

Below is an example of such a function that identifies duplicate values in a column and displays an error message to the user:

```javascript
      {
        name: "email address",
        displayName: "email address",
        description: "Email address of the user",
        validator: async (rows) => {
            let seen = {};
            return rows.map(row => {
                if (seen[row[2]]) {
                    return {
                        errorMessage: 'Duplicate value found. Please check.'
                    };
                }
                seen[row[2]] = true;
                return true;
            });
        }         
      }
```

In this function:

1. We iterate over each element in the `rows` array.
2. For each `row`, we check if the email address at index 2 (`row[2]`) has been seen before. If it has, we add it to the `seen` object.
3. After the loop, if any duplicate email addresses are found (i.e., if the `seen` object contains the email address more than once), we return an error message indicating the duplicate value found.
4. If no duplicate email addresses are found, we return `true` to indicate that the validation passed without any issues.


---

# 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://docs.osmos.io/developer-docs/uploader-client-side-validation/validation-functions-1.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.
