Error messages can be organized into templates.
The template supports
#unless
and#less
conditional statements.
Error message templates support
propName
andvalue
variables.
Key | Template | Description |
---|---|---|
param-required | '{{propName}}' is a required parameter | |
param-invalid-type | '{{propName}}' is a parameter in an invalid type | |
error-default-func | {{propName}}' default function execution error | |
error-default-value | '{{propName}}' default value type error | |
validate-invalid-func | '{{propName}}' is an invalid value | .valid() error message |
validate-default-invalid | value of '{{propName}}' invalid | validate default error message |
You can modify the default error message template.
This setting is applied globally.
Param | Type | Description |
---|---|---|
templateKey | String | - |
template | String | - |
const { Message } = require('aws-lambda-middleware')
Message.setTemplate('param-required', `'{{propName}}' is a required parameter`)
Error message templates support
propName
,value
,option
, and optionkey
variables.
#unless
, #less
conditional statements.
length of '{{propName}}'{{#unless max}} can be from {{#unless min}}{{min}} {{/unless}}~ {{max}}{{/unless}}{{#less max}} must be {{option}}{{/less}}