liveBook · Manning

Client-side validation

As explained in Building Web APIs with ASP.NET Core

Client-side validation is the checking of user input in the client application before a request is sent to a server.

Client-side validation checks user input in the client before sending a request. In SwaggerUI, parameter rules from swagger.json automatically reject clearly invalid values before a server round trip. section 6.1.4

For the board-game API, client-side validation provides:

  • Immediate feedback when a GET /BoardGames parameter contains the wrong type, such as text instead of an integer. section 6.1.4
  • Fewer useless requests and a faster, clearer presentation layer experience. section 6.1.4
  • No security guarantee: users can bypass browser controls, so the API must validate every input on the server. section 6.1.4

Testing GET /BoardGames

Open the SwaggerUI endpoint, expand GET /BoardGames, choose Try It Out, enter invalid values, and select Execute. SwaggerUI displays corrections without making the request. section 6.1.4

{
  "name": "PageIndex",   #1
  "in": "query",
  "schema": {
    "type": "integer",   #2
    "format": "int32",   #3
    "default": 0         #4
  }
},
{
  "name": "PageSize",    #5
  "in": "query",
  "schema": {
    "maximum": 100,
    "minimum": 1,
    "type": "integer",   #6
    "format": "int32",   #7
    "default": 10        #8
  }
}

The generated parameter schema shows client-visible types, formats, defaults, and page-size limits used by SwaggerUI. section 6.1.4

How Building Web APIs with ASP.NET Core covers it

How deep it goes
Demonstrates automatic SwaggerUI checks and their limits, but defers implementation of general client-side validation controls.
Examples
Uses GET /BoardGames parameters, invalid integer input, Try It Out, and generated parameter constraints.
What it assumes
Assumes familiarity with HTTP endpoints and parameters while demonstrating the validation workflow through SwaggerUI.
What you can do after
Apply it via SwaggerUI to catch invalid inputs early, while retaining server-side checks for data integrity.
How it connects
Connects client-side validation with SwaggerUI, OpenAPI, swagger.json, and server-side validation.

Also explained in

Compare how 5 books explain client-side validation →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Building Web APIs with ASP.NET Core. The section links point to the parts of the book it draws on.