-
Notifications
You must be signed in to change notification settings - Fork 248
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
(feat) O3-2779: Error messages in drug order form should be translated #1652
Conversation
Size Change: +27.9 kB (0%) Total Size: 10.7 MB
ℹ️ View Unchanged
|
dosage: z.number({ | ||
invalid_type_error: translateFrom(moduleName, 'dosageRequiredErrorMessage', 'A dosage is required'), | ||
}), | ||
|
||
// t( 'selectUnitErrorMessage', 'Please select a unit' ) | ||
unit: z.object( | ||
{ ...comboSchema }, | ||
{ | ||
invalid_type_error: translateFrom(moduleName, 'selectUnitErrorMessage', 'Please select a unit'), | ||
}, | ||
), | ||
|
||
// t( 'selectRouteErrorMessage', 'Please select a route' ) | ||
route: z.object( | ||
{ ...comboSchema }, | ||
{ | ||
invalid_type_error: translateFrom(moduleName, 'selectRouteErrorMessage', 'Please select a route'), | ||
}, | ||
), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not directly related to your changes, but it appears that invalid_type_error
is getting conflated with required_error
here.
Per the Zod documentation, invalid_type_error
is intended to customize the error message for type mismatches. This means it will trigger an error if the data types of the provided values do not align with those specified in the schema. So in this case, we'll expect to see the error if the provided content is not a string.
However, the current error messages suggest an intent to enforce the presence of these fields, which aligns more closely with the purpose of required_error
.
Thanks, @vasharma05! We should probably document how to use |
packages/esm-patient-medications-app/src/add-drug-order/drug-order-form.component.tsx
Show resolved
Hide resolved
Co-authored-by: Dennis Kigen <[email protected]>
This reverts commit d11523e.
Requirements
Summary
This PR allows translating the error messages in the drug order form. The Zod schema is defined outside a component/ hook, hence I used
translateFrom
to take care of the translations.Screenshots
None
Related Issue
https://issues.openmrs.org/browse/O3-2779
Other
None