-
Notifications
You must be signed in to change notification settings - Fork 671
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
Schema validation package #85
Comments
Just remembered there's also the |
Would you consider also using typescript for that? I think that would increase the adoption and help with completion etc in IDEs. |
I think some sort of typescript support would be nice – but I think there’s value in having a runtime schema validating as well. If you have ideas for anything to add to make typescript development better, I think that could make a great addition to the library as a whole |
I think to have good TS support would require to write the library in TS. Not sure what’s your stance on that. I’d love to have first-class TS support out of the box. |
We’ll probably not change the core to use ts since we want to keep a fairly low barrier to contribute, but I’m guessing some optional ts-specific packages could make sense. Especially around creating and using the theme object - at the very least some type definition modules could probably help |
I started prototyping this: https://codesandbox.io/embed/compassionate-euler-xgzxb?codemirror=1 Some questions:
|
I have been building something that generates css variables from the schema. I think this would be an abstraction from the actual schema as the schema should be able to generate react props, css variables, sass variables, design files, spreadsheets etc. |
@alex-page that's where my gut goes too, but I'm not certain that it's the right decision. |
@VinSpee after reading this article by the maintainer I think that is there intention:
|
yes, and also from Brent: https://twitter.com/jxnblk/status/1142137365164646402
|
@alex-page I think this would be a great addition to theme-ui as a stand-alone package. I imagine the schema package would be something that could be leveraged for this, but it probably warrants its own issue if you’re keen to contribute |
@VinSpee that looks awesome! I don't know if I have any definitive answers for you, but here's my initial thoughts:
I think that would be good. A lot of people use nested color objects, so it'd be great if most existing styled-system and related themes would still be "valid" so to speak.
If you mean should you be able to add custom properties as values to the theme object, then I think the answer would be yes. There could be additional stuff built on top to help with how those custom properties actually map to the theme object, but I think that would be out of scope here |
Would love to contribute. I made an issue #128, I have a rough work in progress here however it requires a lot more to be done. |
For that matter there is also |
Could always use jsonschema, it is an open standard for this exact purpose. Not sure if you can find a tiny library to do it though, |
Okay. I'm in need of JSON Schema for the |
@hasparus My read 2+ years later here is great TypeScript support is enough (which we've got other issues for improving)—I think of TypeScript as the default for most developers, & if you're not using it you're aware you're missing out on validation all over the codebase. I'm not sure what you'd use this package for beyond that. Any other thoughts? |
@lachlanjc I'd keep this open, but the main reason an user would need this package is when you validate Theme UI themes at runtime... so if you build an app that's used to build other websites — like a CMS, or a MySpace profile page. Not a very popular use case. I'd try ts-json-schema-generator as a starting point. |
A schema validation for Theme UI objects could help with other packages and libraries built on top of the core. Leveraging a library like
yup
orjoi
, this validator should be able to detect whether a theme object is valid and detect typos among other thingsThe text was updated successfully, but these errors were encountered: