Skip to main content
zerotal

Documentation


Documentation / @zerotal/flow / index / validate

Function: validate()

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

Defined in: flow/src/decorators.ts:739

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).

Example

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 = "";
}