liveBook · Manning

Validation

As explained in Rust Servers, Services, and Apps

Input validation is the process of checking supplied data against format, length, type, or business constraints before processing it.

Input validation checks form data before processing it and gives users feedback when their entries are invalid. In web forms, checks can run in the browser or in a server handler. section 8.0 section 8.4

Choose where to validate based on the check:

  • Use browser-side HTML checks for simple constraints such as field length; feedback can appear without sending a request to the server. section 8.4 section 9.1
  • Check complex conditions in the server handler, such as whether a username is already registered. On errors, re-render the form with a suitable message. section 8.4

Tutor forms

A registration form accepts a username, password, password confirmation, tutor name, image URL, and profile. A sign-in form accepts a username and password; failed authentication returns the form with an error message. section 8.0 section 9.1

Figure 8.1 Tutor registration form

The tutor registration form shows the kind of multi-field form whose submitted data needs validation. section 8.0

How Rust Servers, Services, and Apps covers it

How deep it goes
Distinguishes simple browser checks from complex handler checks, without detailing their implementation.
Examples
Uses tutor registration fields, sign-in credentials, field-length checks, and username availability as examples.
What you can do after
Apply basic checks in HTML and complex checks in handlers, then return invalid forms with suitable feedback.
How it connects
Connects HTML forms and HTTP POST requests to Actix handlers, authentication, and database-backed username checks.

Also explained in

Compare how 30 books explain validation →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Rust Servers, Services, and Apps. The section links point to the parts of the book it draws on.