# Getting started

The biggest difference when switching to React Advanced Form validation is that it diverges from a conventional single `validate` function and uses a dedicated [validation schema](/react-advanced-form/validation/schema.md) to determine the next validity state of the fields.

## Validation types

Any field supports synchronous and asynchronous validation, and any combination of those.

{% hint style="success" %}
React Advanced Form comes with a smart multi-layer validation built-in. Learn more on the [Priority & Exclusion](/react-advanced-form/validation/schema.md#priority-and-exclusion) of the validation rules.
{% endhint %}

## Validation schema

The majority of validation rules reside in the dedicated validation schema. It is a good place to start declaring validation in your application.

{% content-ref url="/pages/-LLiIbgRQ\_8oMu9GoBM5" %}
[Validation schema](/react-advanced-form/validation/schema.md)
{% endcontent-ref %}

## Applying validation

There are multiple ways to apply validation to a field (listed by priority, from highest to lowest):

* [Field-specific](/react-advanced-form/components/field/props/rule.md) rules
* [Form-specific](/react-advanced-form/components/form/props/rules.md) rules
* [Application-wide](/react-advanced-form/components/form-provider.md) rules

## Validation messages

Validation is a communication between your system and a user. Converse clearly with our versatile API and smart fallback system. Take advantage of the key features of a validation message:

* Completely decoupled from the validation schema
* Each message can be a function that accepts the field's `value`, `fieldProps`, `fields` and `form`, and returns the message string
* Allows to associate a message with a specific rule name

{% content-ref url="/pages/-LDfz\_oVDh8KWpUAMEwO" %}
[Validation messages](/react-advanced-form/validation/messages.md)
{% endcontent-ref %}

## Validity state

The result of a validation is reflected in the validity state. It contains two properties:

* `valid` (boolean)
* `invalid` (boolean)

Those properties can be accessed on the `fieldProps` in a field component declaration and various callback methods. We recommend to base the validation UI based on the validity state.

{% hint style="warning" %}
Please note that `valid` and `invalid` states are not interchangeable, thus:
{% endhint %}

```javascript
!fieldProps.valid !== fieldProps.invalid
```

This value separation is crucial for initial validity state. When a field is mounted, it is neither valid, nor invalid, thus the values of both properties are set to `false`. Further field interactions update the validity state correspondingly.

{% content-ref url="/pages/-LDfz\_nty5ZDkfZhhZj9" %}
[Exposed props](/react-advanced-form/hoc/create-field/exposed-props.md)
{% endcontent-ref %}

## Backwards compatible

We are using a specific validation format—[validation schema](/react-advanced-form/validation/schema.md). It is, however, a plain Object that can be used even without React Advanced Form.


---

# 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://redd.gitbook.io/react-advanced-form/validation/getting-started.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.
