[**Documentation**](../../../../README)

***

[Documentation](../../../../README) / [@zerotal/flow](../../README) / [index](../README) / validate

# Function: validate()

> **validate**(`build`): (`value`, `context`) => `void`

Defined in: [flow/src/decorators.ts:739](https://github.com/zerotaldev/zerotal/blob/1d6fb26b05b18ba077de1bfaeb46c42131cd8b70/packages/flow/src/decorators.ts#L739)

Attaches a validation rule to a field using the framework validator's fluent chain.

## Parameters

### build

`ValidateBuilder`

A ValidateBuilder that builds the field rule from the chain API.

## Returns

A field decorator that registers the rule.

(`value`, `context`) => `void`

## Remarks

The rule is read by `this.validate()` (called with no argument) and by real-time validation on
client update. `@validate` only registers the rule — it does not expose the field, so pair it
with `@expose` for client-editable inputs. Applies to a field only. The decorator-attached
rules mirror the object form accepted by `this.validate({ ... })` (see [ValidationRules](../type-aliases/ValidationRules)).

## Example

```tsx
class SignupForm extends Component {
  @expose @validate((rule) => rule.required().min(2).max(50)) name = "";
  @expose @validate((rule) => rule.required().email()) email = "";
  @expose @validate((rule) => rule.required().min(8).confirmed()) password = "";
}
```
