input validation

Checking that data from a user, file or caller is acceptable before using it, and rejecting or asking again if not.

In more detail

Validation rejects data that is the wrong type, out of range, badly formed or too large before it can cause errors or security problems. For a web API this means checking every part of a request, such as headers, body size and field values, against the contract at the boundary, before any query is built. A function or service that receives impossible input should signal a clear error rather than return a wrong answer.

Example

The course loops until input passes string checks such as isdigit, or catches ValueError from int().

Related terms

Taught in

References