Once the view model is filled up by the user, we rely on a function to validate and convert the data into a structure easy to handle within a template.
On the other hand if the proper output annotations have been used in the model definition, such method can be automatically generated for you.
The function definition is as follow:
module.exports = function (viewModel) { |
- model: Pass the data model as you receive it.
- errors: Is an array of error message as strings. Should be null or undefined if no error.
- results: Is a map where the key is the file path that needs to be created and the value its content.
- copies: Is a list of files that needs to be copied over without modification. The source path need to be absolute while the destination one will be relative to the target directory of where the files will be created.
- permissions: Is a map for which default permission should be altered such as adding execution support for a shell script.
View Model structure
The view model is what you get from the outside world that you need to convert into a set of files. That structure is related to the definition you wrote and what the user actually filled in.
{ |
{ |