liveBook · Manning

Validation

As explained in Coding with AI

Validation is the checking of input or application state against expected rules and constraints.

Validation checks input, application state, or generated suggestions against expected rules and constraints. It prevents vague assumptions, unchecked submissions, and unreviewed code from becoming accepted results. section 3.9 section 7.1

Use validation as a practical workflow:

  • Define the expected task, context, functionality, and constraints before judging a result. section 3.9 section 7.1
  • Check submitted values, including cases where a user sends a form without selecting an answer. section 7.1.1
  • Test database retrieval, answer storage, navigation, and completion behavior instead of trusting a plausible implementation. section 7.1.1
  • Compare multiple AI responses, reject overengineered suggestions, and apply technical judgment to the final design. section 3.9 section 7.1.1

Validating a quiz submission

A Flask quiz displays one question with radio-button answers. The answer route receives the selected value and question identifier, stores the response, retrieves the next question, and finishes when none remains. Validation adds a check for an unselected answer and error handling for database or retrieval failures. The implementation still needs testing to confirm that questions, responses, redirects, and completion behave as intended. section 7.1 section 7.1.1

<!-- templates/question.html -->
<html>
<head>
    <title>Quiz Question</title>
</head>
<body>
    <form action="/answer" method="post">
        <h2>{{ question.question_text }}</h2>
        {% for option in question.options %}
        <input type="radio" name="answer" 
value="{{ loop.index }}">{{ option }}<br>
        {% endfor %}
        <input type="submit" value="Submit">
    </form>
</body>
</html>

Inspect the Jinja form to see where user input enters the application and where answer-selection checks belong. section 7.1.1

How Coding with AI covers it

How deep it goes
Demonstrates requirements checks, form handling, error cases, testing, and human review, but does not detail validation implementation internals.
Examples
Uses a Flask quiz form, stored answers, question navigation, database testing, and review of an overengineered SQLAlchemy proposal.
What it assumes
Assumes basic application requirements and developer judgment while teaching validation through concrete Flask form and workflow checks.
What you can do after
Diagnose missing inputs, implementation failures, and unsuitable AI suggestions before deploying or adopting them.
How it connects
Connects validation with prompting, error handling, testing, databases, routing, and technical judgment.

Also explained in

Compare how 30 books explain validation →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Coding with AI. The section links point to the parts of the book it draws on.