Skip to content
This repository was archived by the owner on Nov 8, 2024. It is now read-only.

Commit 290dec8

Browse files
feat: removes "severity" from error messages
1 parent e5c4f72 commit 290dec8

File tree

5 files changed

+9
-17
lines changed

5 files changed

+9
-17
lines changed

lib/next/units/isValid.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
function isValidComponent(errors) {
2-
return errors.every((error) => error.severity !== 'error');
2+
return errors.length === 0;
33
}
44

55
// Returns a boolean indicating whether a given validation result
66
// concludes two HTTP messages as valid (matching).
77
// Separated into its own util only to be used in both next and legacy API.
88
function isValid(validationResult) {
9-
return Object.values(validationResult.field).every((resultGroup) => {
9+
return Object.values(validationResult.fields).every((resultGroup) => {
1010
return isValidComponent(resultGroup.errors);
1111
});
1212
}

lib/next/units/validateBody.js

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -180,21 +180,17 @@ function validateBody(real, expected) {
180180

181181
if (realTypeError) {
182182
errors.push({
183-
message: realTypeError,
184-
severity: 'error'
183+
message: realTypeError
185184
});
186185
}
187186

188187
if (expectedTypeError) {
189188
errors.push({
190-
message: expectedTypeError,
191-
severity: 'error'
189+
message: expectedTypeError
192190
});
193191
}
194192

195-
const hasErrors = errors.some((result) =>
196-
['error'].includes(result.severity)
197-
);
193+
const hasErrors = errors.length > 0;
198194

199195
// Skipping body validation in case errors during
200196
// real/expected body type definition.
@@ -204,8 +200,7 @@ function validateBody(real, expected) {
204200

205201
if (validatorError) {
206202
errors.push({
207-
message: validatorError,
208-
severity: 'error'
203+
message: validatorError
209204
});
210205
}
211206

lib/next/units/validateHeaders.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,7 @@ No validator found for real data media type
3737
"${realType}"
3838
and expected data media type
3939
"${expectedType}".\
40-
`,
41-
severity: 'error'
40+
`
4241
});
4342
}
4443

lib/next/units/validateMethod.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,7 @@ function validateMethod(real, expected) {
88

99
if (!isValid) {
1010
errors.push({
11-
message: `Expected "method" field to equal "${expectedMethod}", but got "${realMethod}".`,
12-
severity: 'error'
11+
message: `Expected "method" field to equal "${expectedMethod}", but got "${realMethod}".`
1312
});
1413
}
1514

lib/next/units/validateStatusCode.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,7 @@ function validateStatusCode(real, expected) {
1313
errors.push({
1414
message: `Status code is '${real.statusCode}' instead of '${
1515
expected.statusCode
16-
}'`,
17-
severity: 'error'
16+
}'`
1817
});
1918
}
2019

0 commit comments

Comments
 (0)