-
-
Notifications
You must be signed in to change notification settings - Fork 3.1k
Use config schema definition for validation. #1363
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
Conversation
Deploy preview for netlify-cms-www ready! Built with commit ad12707 |
Deploy preview for cms-demo ready! Built with commit ad12707 |
I haven't updated the entire schema yet (this is still a WIP), but I've added all the validations we were currently doing in-code. I think most error messages are clear enough, but for more complicated stuff like Example error messages. I'd like opinions on which of these are unclear and need updated.
|
I think these are fine for a start, we can always improve moving forward. |
1c8393a
to
8e34db6
Compare
@erquhart Can you review this on a "real" config file (e.g. Netlify, Smashing, etc.)? |
@Benaiah Any thoughts on this? |
i can't wait for this!! |
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.
@tech4him1 this is awesome - just one change needed, otherwise LGTM. I might go ahead and rebase since it's my fault it's behind lol.
src/constants/configSchema.js
Outdated
widget: { type: "string" }, | ||
required: { type: "boolean" }, | ||
}, | ||
required: ["name", "label", "widget"], |
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.
widget
isn't required, it's string
by default.
}, | ||
}, | ||
}, | ||
required: ["name", "label"], |
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.
Should we drop label
too since that is a pending PR?
src/constants/configSchema.js
Outdated
widget: { type: "string" }, | ||
required: { type: "boolean" }, | ||
}, | ||
required: ["name", "label"], |
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.
Should we drop label
too since that is a pending PR?
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.
yeah, makes sense - I'm pushing another commit right now, will include that.
CI will fail until I merge the new stuff from #1573. |
- Summary
Closes #487.
I was just thinking about the best method for config validation, and this seemed like a viable option. @Benaiah's validator may be better, but I think it's worth a comparison.
This kind of basic format definitely does have the downside of only being able to statically check things. Most logic is available, though, and we can import constants from other files (valid formats, for example).
- Test plan
- Description for the changelog
Validate config with schema.
- A picture of a cute animal (not mandatory but encouraged)