Validation Feedback Simulator
Run the Validation Feedback Simulator MicroSim Fullscreen
You can experiment with the code by pasting validation-simulator.js into the p5.js Editor.
About This MicroSim
A document can be perfectly good JSON and still be the wrong shape. Syntax rules say where the quotes and commas go. A schema says which properties must be present, what type each value must be, and which values are allowed.
This MicroSim acts like a schema validator for MicroSim metadata. The editor
on the left holds a metadata.json document. The panel on the right lists
every problem the validator found:
| Marker | Meaning | What to do |
|---|---|---|
| Red circle with an X | Error: the document violates the schema | Must be fixed |
| Yellow triangle | Warning: valid, but a quality suggestion | Consider improving |
| Green check mark | Valid: the document matches the schema | Ready to use |
Each issue reports the same four facts a real validator gives you: the
message, the location as a path such as /educational/difficulty, the
current value, and what was expected. Lines with issues are marked in
the gutter of the editor.
The validator checks the teaching version of the schema from Chapter 5:
dublinCoreis the only required sectiontitle,creator,subject,description,date,format, andrightsare requiredtitlemust be 3 to 100 characters,datemust look likeYYYY-MM-DD, andsubjectmust contain at least one stringgradeLevel,difficulty, andbloomsTaxonomymust use values from a fixed list
How to Use
- The MicroSim starts with a document that has three errors. Read the three messages.
- Click an issue to open its details. The editor jumps to the line and selects the problem.
- Decide how to fix it, then edit the JSON. The document is checked again on every keystroke, and the issue disappears from the list when it is fixed.
- Watch the progress bar count the issues you have fixed.
- If you are stuck, check Show hints to see a suggested fix for the selected issue.
- Press Auto-fix to see which problems a program can repair by itself (a misspelled key,
a value such as
"Easy"that has an obvious replacement, wrong quotes) and which ones need information only a person can supply (a missing description, an empty subject list). - Use Load Example to practice one kind of error at a time, and Reset to Original to start an example again.
Iframe Embed Code
You can add this MicroSim to any web page by adding this to your HTML:
1 2 3 4 | |
Lesson Plan
Learning Objective
Students will distinguish between valid and invalid JSON metadata by analyzing validation feedback and correcting errors to produce schema-compliant documents. (Bloom's Taxonomy: Analyze)
Grade Level
Undergraduate and adult learners
Duration
15-20 minutes
Prerequisites
- Can write valid JSON syntax
- Knows what required fields, data types, and enums are in a JSON Schema
- Has read the "Schema Validation: Checking Your Work" section of Chapter 5: JSON and Data Structures
Activities
- Classify (4 min): With hints off, students read the three starting errors and label each one: missing required field, wrong type, or invalid enum value.
- Repair (6 min): Students fix all three errors by editing the JSON and watch the progress bar reach 3 of 3.
- One at a time (5 min): Students load the Array error and Misspelled key examples and explain each message in their own words before fixing it.
- Human or machine? (3 min): Reset the three-error example and press Auto-fix. Discuss why the tool could repair one error but not the other two.
- Break it (2 min): Load Valid metadata and make it invalid in a way not shown in the examples. What does the validator report?
Assessment
- Given an error message and location, can the student point to the line that must change?
- Can the student tell an error from a warning and explain the difference?
- Can the student explain why valid JSON syntax does not guarantee valid metadata?
References
- Understanding JSON Schema - json-schema.org - Explains
required,type,enum,minItems, and the other keywords behind these error messages. - JSON Schema Validation: A Vocabulary for Structural Validation of JSON - 2022 - json-schema.org - The specification of the validation keywords.
- RFC 6901: JavaScript Object Notation (JSON) Pointer - 2013 - IETF - Defines the
/dublinCore/titlepath notation used in the Location field. - MicroSim Schema documentation - This textbook - The full metadata schema that the teaching version is based on.
- p5.js Reference - p5.js - Documentation for the library used to build this MicroSim.