> For the complete documentation index, see [llms.txt](https://redd.gitbook.io/react-advanced-form/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://redd.gitbook.io/react-advanced-form/components/form/methods/validate.md).

# validate()

## Specification

Performs manual validation of the referenced `Form`.

{% hint style="danger" %}
Always favor conventional form submit via `Button[type="submit"]`. Form validation is obviously included prior to submit action, so there is **no need to explicitly invoke validation**. However, there are use cases to refer to manual validation. Please see those below.&#x20;
{% endhint %}

## Definition

```typescript
type Validate = () => Promise<boolean>
```

## Use cases

There are several use cases when using manual validation may be appropriate, as opposed to conventional form submit flow.

### Submitting multiple forms at once

In this case you may want to validation each form independently, and perform a submit based on the accumulated validity of all forms.

{% hint style="info" %}
Consider [`Field.Group`](/react-advanced-form/components/field-group.md) for semantical separation of the form sections. Using field groups validates and submits all the groups automatically, as they are the part of a single form.
{% endhint %}

### Logic dependent on the runtime validity of a form

You may want to show/hide different UI elements, or perform any subsequent actions based on the validity of a form in the given point of time (apart of submit).

## Example

### Simple example

```jsx
import React from 'react'
import { Form } from 'react-advanced-form'
import { Input } from 'react-advanced-form-addons'

export default class Example extends React.Component {
  handleClick = () => {
    this.form.validate().then((isFormValid) => {
      // ...
    })
  }

  render() {
    return (
      <div>
        <Form ref={form => this.form = form}>
          <Input
            name="username"
            required />
        </Form>
        <a href="#" onClick={this.handleClick}>Validate</a>
      </div>
    )
  }
}
```

### Using async/await

Since validate function returns a Promise, you can use async/await to retrieve the validity of a form in a single line:

```javascript
handleClick = async () => {
  const isFormValid = await this.form.validate()
}
```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## 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, and the optional `goal` query parameter:

```
GET https://redd.gitbook.io/react-advanced-form/components/form/methods/validate.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
