Documentation ¶
Overview ¶
Package generator builds an Agreement from a Template.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Do ¶
Do generates an agreement from a generator model.
This generator receives a model, which contains a Template and a list of variables with their values, and substitutes the placeholders in the template the appropriate variable values. The output is an agreement.
The generator uses text/template syntax for the substitution of the placeholds, i.e., placeholders are of the type {{.var}} to substitute the value of {{.var}} with the value of the key 'var' in the model.Variables map.
A right template should define placeholders in the following paths:
- Details.Client
- Details.Provider if the template is used by more than one provider (if not, the provider can be hardcoded in the template)
- Details.Name
Placeholders may be defined in other paths, e.g. Guarantee[i].Constraint, Details.Expiration
After the substitution, the following fields are modified, regardless of the template content:
- Details.Type: set to agreement type
- Details.Id: UUID value
- Id: equals to agreement.Details.Id
- Details.Creation: current time
- Name: equal to agreement.Details.Name
An error of type validation is returned if the validation on the generated agreement fails. An error of type unreplaced is returned if there is a placeholder that is not substituted. Use IsErrValidation and IsErrUnreplaced to check type of an error.
func IsErrUnreplaced ¶
IsErrUnreplaced checks that the err is an ErrUnreplaced error
func IsErrValidation ¶
IsErrValidation checks that the err is an ErrValidation error