You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardexpand all lines: www/apps/book/app/learn/fundamentals/modules/options/page.mdx
+45
Original file line number
Diff line number
Diff line change
@@ -118,3 +118,48 @@ export default async function helloWorldLoader({
118
118
)
119
119
}
120
120
```
121
+
122
+
---
123
+
124
+
## Validate Module Options
125
+
126
+
If you expect a certain option and want to throw an error if it's not provided or isn't valid, it's recommended to perform the validation in a loader. The module's service is only instantiated when it's used, whereas the loader runs the when the Medusa application starts.
127
+
128
+
So, by performing the validation in the loader, you ensure you can throw an error at an early point, rather than when the module is used.
129
+
130
+
For example, to validate that the Hello Module received an `apiKey` option, create the loader `src/modules/loaders/validate.ts`:
0 commit comments