Skip to content

Commit

Permalink
template: Make validation errors from failed enum matches shorter
Browse files Browse the repository at this point in the history
The list of allowed values has been moved from "messages" to "details".
  • Loading branch information
mstokes-f5 committed Oct 3, 2023
1 parent d2ae90b commit 7039c73
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
4 changes: 2 additions & 2 deletions lib/template.js
Original file line number Diff line number Diff line change
Expand Up @@ -1092,8 +1092,8 @@ class Template {
}

if (error.keyword === 'enum') {
const allowedValues = error.params.allowedValues;
message = `${message}: ${allowedValues.join(', ')}`;
const allowedValues = error.params.allowedValues.join(', ');
details = `allowed values are: ${allowedValues}`;
}

if (error.keyword === 'pattern') {
Expand Down
3 changes: 2 additions & 1 deletion test/template.js
Original file line number Diff line number Diff line change
Expand Up @@ -1349,7 +1349,8 @@ describe('Template class tests', function () {
message: 'parameter fooArray[1] should be of type string'
},
{
message: 'parameter fooEnum should be equal to one of the allowed values: foo, bar'
message: 'parameter fooEnum should be equal to one of the allowed values',
details: 'allowed values are: foo, bar'
},
{
message: 'parameter foo should be of type string'
Expand Down

0 comments on commit 7039c73

Please sign in to comment.