<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://neowiki.dev/w/index.php?action=history&amp;feed=atom&amp;title=Validation_Demo</id>
	<title>Validation Demo - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://neowiki.dev/w/index.php?action=history&amp;feed=atom&amp;title=Validation_Demo"/>
	<link rel="alternate" type="text/html" href="https://neowiki.dev/w/index.php?title=Validation_Demo&amp;action=history"/>
	<updated>2026-06-16T16:08:19Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.43.8</generator>
	<entry>
		<id>https://neowiki.dev/w/index.php?title=Validation_Demo&amp;diff=284&amp;oldid=prev</id>
		<title>NeoWiki: Importing NeoWiki demo data</title>
		<link rel="alternate" type="text/html" href="https://neowiki.dev/w/index.php?title=Validation_Demo&amp;diff=284&amp;oldid=prev"/>
		<updated>2026-06-11T11:31:15Z</updated>

		<summary type="html">&lt;p&gt;Importing NeoWiki demo data&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;A live testbed for trying out NeoWiki&amp;#039;s backend validation and seeing how the editor surfaces server-side errors next to each field.&lt;br /&gt;
&lt;br /&gt;
== Setup ==&lt;br /&gt;
&lt;br /&gt;
Turn enforcement on in &amp;lt;code&amp;gt;LocalSettings.php&amp;lt;/code&amp;gt;:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
$wgNeoWikiEnforceValidation = true;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
With this flag on, writes that introduce new violations are rejected with HTTP 422 and the editor renders the violations inline. With it off, writes always go through and the violations come back in the 200 response for informational purposes only.&lt;br /&gt;
&lt;br /&gt;
== Demo subjects ==&lt;br /&gt;
&lt;br /&gt;
* [[Validation Clean]] — a Subject with every property filled in correctly. Use it as the starting point for the recipes below.&lt;br /&gt;
&lt;br /&gt;
The [[Schema:Validation Demo|Validation Demo]] schema has four properties spanning the validation surface:&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Property !! Type !! Notes&lt;br /&gt;
|-&lt;br /&gt;
| Title || text, required || A simple required text field.&lt;br /&gt;
|-&lt;br /&gt;
| Homepage || url, required || A single required URL. Empty triggers a &amp;quot;required&amp;quot; error inline.&lt;br /&gt;
|-&lt;br /&gt;
| Tags || url, multi || Optional list of URLs. Changing one entry to a non-http(s) URL triggers a per-entry &amp;lt;code&amp;gt;invalid-url&amp;lt;/code&amp;gt; violation under enforcement; only the offending sub-input is decorated.&lt;br /&gt;
|-&lt;br /&gt;
| Status || select, required || A required choice between three options.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Recipes ==&lt;br /&gt;
&lt;br /&gt;
;&amp;#039;&amp;#039;&amp;#039;See an inline error.&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
Open [[Validation Clean]], switch to the Subjects tab, and click &amp;#039;&amp;#039;&amp;#039;Edit&amp;#039;&amp;#039;&amp;#039; on the main subject. Backspace the value in &amp;#039;&amp;#039;&amp;#039;Title&amp;#039;&amp;#039;&amp;#039; and click &amp;#039;&amp;#039;&amp;#039;Save changes&amp;#039;&amp;#039;&amp;#039;. The dialog stays open, the Title field gets a red border with &amp;quot;Please provide a value.&amp;quot;, and a toast appears: &amp;#039;&amp;#039;Validation failed for &amp;quot;Validation Clean&amp;quot;. Please fix the highlighted fields.&amp;#039;&amp;#039; The PUT in the network panel returns &amp;lt;code&amp;gt;422&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
;&amp;#039;&amp;#039;&amp;#039;See the error clear as you type.&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
Trigger the inline error above, then type any character into the Title field. The red border disappears immediately, before you click Save again. The dialog wires the input back up to drop the matching server-side violation as soon as you edit.&lt;br /&gt;
&lt;br /&gt;
;&amp;#039;&amp;#039;&amp;#039;See the success path still work.&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
Set &amp;lt;code&amp;gt;$wgNeoWikiEnforceValidation = false&amp;lt;/code&amp;gt; and repeat the empty-Title save. The PUT now returns &amp;lt;code&amp;gt;200&amp;lt;/code&amp;gt;, the dialog closes, and the success toast fires. The 200 body still mentions the violation but it&amp;#039;s advisory only — no inline marking, no rejection. This proves the step-1 contract from PR #855 still holds.&lt;br /&gt;
&lt;br /&gt;
;&amp;#039;&amp;#039;&amp;#039;See a create-side error.&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
With enforcement on, click &amp;#039;&amp;#039;&amp;#039;Add subject&amp;#039;&amp;#039;&amp;#039; under &amp;quot;Other Subjects on this Page&amp;quot;, choose &amp;#039;&amp;#039;&amp;#039;Validation Demo&amp;#039;&amp;#039;&amp;#039;, leave Title empty, and click &amp;#039;&amp;#039;&amp;#039;Create subject&amp;#039;&amp;#039;&amp;#039;. The create dialog behaves the same as the edit dialog: 422, dialog stays open, Title decorated, validation-failed toast.&lt;br /&gt;
&lt;br /&gt;
;&amp;#039;&amp;#039;&amp;#039;See a per-entry error on a multi-value field.&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
With enforcement on, open [[Validation Clean]] → edit the main subject. Change the second &amp;#039;&amp;#039;&amp;#039;Tags&amp;#039;&amp;#039;&amp;#039; entry from &amp;lt;code&amp;gt;https://example.com/b&amp;lt;/code&amp;gt; to &amp;lt;code&amp;gt;ftp://example.com/b&amp;lt;/code&amp;gt; and click &amp;#039;&amp;#039;&amp;#039;Save changes&amp;#039;&amp;#039;&amp;#039;. Confirm: only the second sub-input gets the red border, the first stays clean. The 422 body carries &amp;lt;code&amp;gt;valuePartIndex: 1&amp;lt;/code&amp;gt;, which the editor uses to target just that input.&lt;br /&gt;
&lt;br /&gt;
;&amp;#039;&amp;#039;&amp;#039;Form-level banner.&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
This one is reachable only when a violation has no field anchor (e.g. &amp;lt;code&amp;gt;schema-not-found&amp;lt;/code&amp;gt;, or a property removed from the schema after a Subject was saved). The component tests cover it; there&amp;#039;s no clean UI reproduction against this schema. Verify in the test suite.&lt;br /&gt;
&lt;br /&gt;
== Backend wire shape ==&lt;br /&gt;
&lt;br /&gt;
A 422 body from the persistence layer looks like:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;json&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
  &amp;quot;status&amp;quot;: &amp;quot;error&amp;quot;,&lt;br /&gt;
  &amp;quot;message&amp;quot;: &amp;quot;Validation failed&amp;quot;,&lt;br /&gt;
  &amp;quot;violations&amp;quot;: [&lt;br /&gt;
    { &amp;quot;propertyName&amp;quot;: &amp;quot;Title&amp;quot;, &amp;quot;code&amp;quot;: &amp;quot;required&amp;quot;, &amp;quot;args&amp;quot;: [], &amp;quot;valuePartIndex&amp;quot;: null }&lt;br /&gt;
  ]&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The frontend parses this in &amp;lt;code&amp;gt;RestSubjectRepository&amp;lt;/code&amp;gt; and throws a typed &amp;lt;code&amp;gt;ValidationFailedError&amp;lt;/code&amp;gt;. Both &amp;lt;code&amp;gt;SubjectEditorDialog&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;SubjectCreatorDialog&amp;lt;/code&amp;gt; catch it and feed the violations into the editor&amp;#039;s reactive state. Each violation routes by &amp;lt;code&amp;gt;propertyName&amp;lt;/code&amp;gt; (and &amp;lt;code&amp;gt;valuePartIndex&amp;lt;/code&amp;gt; for multi-value inputs) to the matching field. Violations without an anchor fall into a form-level banner above the editor.&lt;br /&gt;
&lt;br /&gt;
== References ==&lt;br /&gt;
&lt;br /&gt;
* [[Schema:Validation Demo]] — the schema source&lt;br /&gt;
* [[Special:Schemas]] — all schemas in the wiki&lt;/div&gt;</summary>
		<author><name>NeoWiki</name></author>
	</entry>
</feed>