Validate a business request with Python
Version: sample-software-v1 · Next content review: 2026-10-22
The business case
A regional retailer accepts stock adjustment requests. Invalid quantities create inaccurate stock records. The store supervisor needs a predictable validation function before a request reaches approval. This module validates input only; backend permissions are a later prerequisite-gated project milestone.
Before you begin
- Run a Python file in a terminal. If new, complete the worked example first.
What you will demonstrate
- Return a clear result for valid and invalid adjustment quantities.
- Demonstrate boundary cases with repeatable tests.
Lesson
A business rule describes a condition the system must enforce. Here, quantity must be a nonzero integer between -20 and 20. Python bool values behave like integers in some contexts, so use type(value) is int when the rule excludes True and False. Return a result rather than printing inside the function so callers can reuse it. Worked example: def valid(value): return type(value) is int and value != 0 and -20 <= value <= 20. This function does not establish who may approve an adjustment. Authorization must later be checked on the server for every protected operation.
Text alternative / lesson overview
Text-first module: read the explanation, run the starter, write tests, and document the business rule. No video is available for this pilot.
Follow the checkpoints
- Download the software starter kit below. Run python software_starter.py; the unfinished check intentionally fails.
- Guided: write a function taking quantity and returning a boolean using the rule in the lesson.
- Run checks for -20, 20, zero, 21, a string, True, and an empty value. Explain each result.
- Independent: adapt the permitted range for an industry you select, state your rule, and add a new failing case before fixing it.
- Document the boundary between validation and approval authorization.
Resources and starter files
Starter code is intentionally unfinished. Download and run it locally; SkillProof does not execute arbitrary code or provide cloud infrastructure in this release.
Acceptance criteria
- Valid nonzero integers at both limits pass; zero, out-of-range quantities, strings, booleans and None fail.
- The supplied tests pass and at least one learner-authored failing case is demonstrated before correction.
Assessment rubric
- Correctness: all required boundaries return the expected results.
- Reliability: repeatable tests cover wrong types and empty values.
- Explanation: distinguish input validation from permission to approve.
- Evidence: show the failing case, correction, rerun and assistance used. All four criteria are required; no numeric score is automatically awarded.
Check your understanding
A worker can hide an approval button in the browser. What protects the approval operation?
Practice feedback only. This question does not certify independent project competence.Change request
The supervisor changes the allowed range to -10 through 10. Add tests that would catch the previous limits and update your implementation.
Portfolio deliverables
- Python function and runnable tests
- Before/after test output
- A short business-rule explanation and limitations
Tools, permissions and content provenance
Python 3.11+; standard library only. SQLite 3 for data extension. Docker Compose v2 for optional DevOps extension.
Original SkillProof instructional example. All organizations and records are synthetic. Starter kits may be adapted for learner portfolios.
Record your evidence
Save only material you are permitted to share. Evidence is private to your account and labeled self-reported. Saving does not automatically award competence or a credential.