Idea: Add API Validation to Medusa 2.0 Data Models #8490
zulianrizki
started this conversation in
Feature Requests
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Idea: Add API Validation to Medusa 2.0 Data Models
Hey Medusa team and community!
I've been playing around with Medusa 2.0 (loving it so far!), and I had an idea I wanted to throw out there.
The Situation
So, we've got this awesome new data modeling system in Medusa 2.0, right? It's super clean and makes setting up models a breeze. For example:
This is great! It handles migrations, entity models, and even with MedusaService it can sets up CRUD services for us. But here's the thing - I noticed we don't have a built-in way to add API validation.
The Idea
What if we could bake API validation right into our model definitions? We could use something like Zod (or whatever makes the most sense) to add validation rules alongside our field definitions.
Here's a rough idea of how it could look:
Why I Think This Could Be Cool
What do you all think? Some questions we might want to consider:
Looking forward to the discussion!
Beta Was this translation helpful? Give feedback.
All reactions