Issue 147
#147 What do you think?
I am working on try to pass an optional argument that will be evaluated. i.e.
errMessage: "'$fqdn' is invalid."
which would print as:
-host.test.com is invalid
The message can look like:
''$value' is incorrect
$value will be replaced by the instance data. I need to make a change so that it will use path and resolve $value rather then just substituting err.instance.
One issue is that top level properties will return all instance data, if $value is used within the custom error message.
Going to leave it here until I get some feedback. Its quite simple now. If the custom message (value of errMessage) contains $iData then it will replace $iData with instance data.
Of course there are some limitations to this:
- it will replace all occurrences of $iData (can limit this with count)
- you can no longer use $iData in the message
- if the instance data is top level then it will print all instance data
Use cases:
hosts:
type: string
pattern: -regex-
errMessage: "'$iData' does not match the regex pattern. Please see the docs"
Will print:
FAIL ...... 'bad*host*' does not match the regex pattern. Please see the docs ...
or
hosts:
type: string
pattern: -regex-
errMessage: "Config has bad host. Please see the docs"
Will print:
FAIL ...... Config has bad host. Please see the docs ...