Skip to content

Commit 7039c73

Browse files
committed
template: Make validation errors from failed enum matches shorter
The list of allowed values has been moved from "messages" to "details".
1 parent d2ae90b commit 7039c73

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

lib/template.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1092,8 +1092,8 @@ class Template {
10921092
}
10931093

10941094
if (error.keyword === 'enum') {
1095-
const allowedValues = error.params.allowedValues;
1096-
message = `${message}: ${allowedValues.join(', ')}`;
1095+
const allowedValues = error.params.allowedValues.join(', ');
1096+
details = `allowed values are: ${allowedValues}`;
10971097
}
10981098

10991099
if (error.keyword === 'pattern') {

test/template.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1349,7 +1349,8 @@ describe('Template class tests', function () {
13491349
message: 'parameter fooArray[1] should be of type string'
13501350
},
13511351
{
1352-
message: 'parameter fooEnum should be equal to one of the allowed values: foo, bar'
1352+
message: 'parameter fooEnum should be equal to one of the allowed values',
1353+
details: 'allowed values are: foo, bar'
13531354
},
13541355
{
13551356
message: 'parameter foo should be of type string'

0 commit comments

Comments
 (0)