Repository navigation
fix(flow): enforce native form validation and leave script validation to the GUI - #1371
Merged
Merged
Conversation
… to the GUI Review of #1269: only validate.js presence rules were enforced. A browser also checks native HTML constraints, and a form's own script can validate or rewrite values before it submits. - build_body checks required, minlength, maxlength, pattern, min, max and the email, url, number and date input types on what it sends, and the validate.js presence, length, format, numericality and email rules. - A form whose script the API step can't run stays on the GUI: an on* handler on the form or on a sent field (OpenEMR's capitalizeMe rewrites the typed name), a page script listening for submit, or a validate.js rule of another kind (OpenEMR's pastDate). Refused at proposal; unavailable at run time when the live form has it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This was referenced Oct 19, 2026
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…-native-validation
Member
Author
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fifth of six fixes from an external review of #1269. Stacked on #1370 (then #1369, #1368).
Bug
Only validate.js
presencerules were enforced. A browser also checks native HTML constraints before it submits, and a form's own script can validate or rewrite values. The API step skipped both.Fix
Evaluated by the API step (
build_body, on what it sends):required,minlength,maxlength,pattern,min,max, and theemail,url,number/rangeanddateinput types;presence,length,format,numericality,email.Left to the GUI (refused at proposal; at run time the step is unavailable when the live form has it):
on*handler on the form (onsubmit) or on a field the save sends (onchange,oninput,onblur);submit;On the real OpenEMR recording this finds three things:
onsubmit='return submitme(1,event,"DEM",constraints)';onchange='checkSkipConditions();capitalizeMe(this);'on each name field.capitalizeMerewrites the typed value, so the API step would have saved a different name than the GUI;pastDaterule on the date of birth, which the API step never enforced.So the referral save stays on the GUI. The reviewer's escape hatch, letting qualification show that the server enforces a script-only rule, is documented as not built. Python's
reapproximates the browser'spattern; a pattern that doesn't compile keeps the save on the GUI.Tests
tests/test_api_step_native_validation.py(new):onsubmit,onchange, a submit listener, and apastDaterule.80 pass with the API-tier, approval, provenance, URL and other-writes tests.
API_TIER.mdis updated.Synthetic values only.
🤖 Generated with Claude Code