-
Notifications
You must be signed in to change notification settings - Fork 6
Footnote: Custom JSON Schemas
Visual Studio Code allows you to define and "enforce" (the editor displays a warning, not an error if a user schema isn't adhered to) JSON schemas based on a file pattern.
Implementing these custom schemas for your DMBinder data files can be useful for a few reasons:
You can make sure a certain attribute is always provided.
VS Code's Intellisense will suggest and autocomplete names of attributes so you don't have to remember what you called that one template property (provided you setup a JSON schema to match the template) and it can populate attributes with default values if a default is defined in the JSON schema.
You can constrain the value of an attribute, by a list or a regular expression (as pictured above) among other things, making your content consistent instead of needing to remember if you put a space here or uppercased a word there, you can have VS Code enforce consistency for you!
You can get started with some examples by using the DMBinder Yeoman Generator or read up on JSON schema documentation here!
Don't forget! If you create a custom schema, you need to tell VS Code which files will use that schema (you can find more information here).