feat(#1984): style warning-level validation feedback differently from errors - #2009
Open
MaryamMehd wants to merge 1 commit into
Open
feat(#1984): style warning-level validation feedback differently from errors#2009MaryamMehd wants to merge 1 commit into
MaryamMehd wants to merge 1 commit into
Conversation
Add useValidationFeedbackSeverity hook returning { feedback, feedbackSeverity }.
Warning-level targetConstraint violations and OperationOutcome issues now render
with amber helper text and no red border, while error-level feedback continues
to use the existing red styling. useValidationFeedback is kept as a deprecated
thin wrapper for backward compatibility.
Co-authored-by: Cursor <cursoragent@cursor.com>
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.
Summary
Closes #1984
useValidationFeedbackSeverityhook that returns both the feedback message and its severity ('error'|'warning'), sourced fromtargetConstraint.severityCodeandOperationOutcome.issue.severity.useValidationFeedbackhook into a deprecated wrapper around the new hook (backwards-compatible).*Item.tsxcomponents (~25 files) to consume the new hook and passfeedbackSeveritydown to their field components.*Field.tsxcomponents (~20 files) to acceptfeedbackSeverityand apply appropriate styling:useValidationFeedbackSeveritycovering error, warning, and parent-feedback scenarios.How to test locally
1. Check out the branch and install dependencies
2. Build the renderer
3. Start the Playground app
cd apps/smart-forms-app npm run devOpen http://localhost:5173 in your browser and click Playground in the top navigation.
4. Load the test questionnaire
In the Playground, click the questionnaire JSON input area and paste the following questionnaire:
{ "resourceType": "Questionnaire", "id": "test-1984-severity", "status": "active", "title": "Test – Validation Feedback Severity", "item": [ { "linkId": "name", "text": "Full name (min 3 characters — ERROR level)", "type": "string", "extension": [ { "url": "http://hl7.org/fhir/uv/sdc/StructureDefinition/sdc-questionnaire-targetConstraint", "extension": [ { "url": "key", "valueId": "name-min-length" }, { "url": "severity", "valueCode": "error" }, { "url": "expression", "valueString": "%resource.item.where(linkId='name').answer.value.length() >= 3" }, { "url": "human", "valueString": "Full name must be at least 3 characters" } ] } ] }, { "linkId": "nickname", "text": "Nickname (min 2 characters — WARNING level)", "type": "string", "extension": [ { "url": "http://hl7.org/fhir/uv/sdc/StructureDefinition/sdc-questionnaire-targetConstraint", "extension": [ { "url": "key", "valueId": "nickname-min-length" }, { "url": "severity", "valueCode": "warning" }, { "url": "expression", "valueString": "%resource.item.where(linkId='nickname').answer.value.length() >= 2" }, { "url": "human", "valueString": "Nickname is very short — are you sure?" } ] } ] } ] }Click Build Form (or equivalent) to render the questionnaire.
5. Expected behaviour
"A"(1 char)"Alice"(≥ 3 chars)"X"(1 char)"Al"(≥ 2 chars)The key difference from before this fix: warning-level constraints no longer apply a red border — they use amber text only, making them visually distinct from hard errors.
6. Run unit tests
All tests should pass, including the new
useValidationFeedbackSeverity.test.tssuite.Made with Cursor