← All blogs

dust blog

Keep Form Rules on the Request Model

Flutter TextFormField validator code beside a Dust Validation model rule

Flutter form validation usually starts in TextFormField.validator.

That is fine for one field. It gets harder when the same rule also matters before an API call.

Dust Validation keeps the rule on the request model.

Add @Validate(...) to the field. Derive Validate(). Run dust build.

Dust generates model validation and Flutter input helpers for supported field types.

The UI can call the generated validator. The submit path can call request.validate().

One rule source. Two places to use it.

Read the Dust Flutter Forms validation guide.

#Dust #Validation #Flutter #Dart #CodeGeneration