# Validating registrations

Misago implements simple framework for extending process of new user registration with additional checks.

When user submits registration form, within its `clean` method form calls functions defined in `MISAGO_NEW_REGISTRATIONS_VALIDATORS` setting.

Each function is called with following arguments:

* `request` - current HttpRequest instance. You may use it to obtain IP address using form, via `request.user_ip` attribute.
* `cleaned_data` - dict containing cleaned data. Use it too look up user's input that you wish to validate.
* `add_error` - `None` or [`add_error`](https://docs.djangoproject.com/en/%7B%7B%20book.django_version%20%7D%7D/ref/forms/api/#django.forms.Form.add_error) function accepting fieldname and list of errors. Allows you to set validation errors on field.

If function decides to interrup registration process and thus stop user from registering account, it can raise either `django.core.exceptions.ValidationError`, `django.core.exceptions.PermissionDenied`, or set errors on form via `form.add_error` utility.

This validation framework provides you with plenty of power, for example allowing you to write custom validator that queries database for number of registrations that occured for specific IP in last 8 hours, and banning both users and IP address via `ban_ip` or `ban_user` utils from `misago.users.bans` module.


---

# 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://misago.gitbook.io/docs/validatingregistrations.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.
