Skip to content

Commit

Permalink
Fix failing jest test.
Browse files Browse the repository at this point in the history
  • Loading branch information
adcoelho committed Jun 28, 2023
1 parent f392350 commit c2c7d1c
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
2 changes: 1 addition & 1 deletion x-pack/plugins/cases/common/schema/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ describe('schema', () => {
PathReporter.report(limitedArraySchema(NonEmptyString, 1, 1, 'foobar').decode(['a', 'b']))
).toMatchInlineSnapshot(`
Array [
"The length of the field foobar is too short. Array must be of length <= 1.",
"The length of the field foobar is too long. Array must be of length <= 1.",
]
`);
});
Expand Down
8 changes: 5 additions & 3 deletions x-pack/plugins/cases/common/schema/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,10 @@ export const limitedArraySchema = <T extends rt.Mixed>(
(input): input is T[] => rt.array(codec).is(input),
(input, context) =>
either.chain(rt.array(codec).validate(input, context), (s) => {
const fieldNameErrorMessage =
fieldName != null ? `The length of the field ${fieldName} is too short. ` : '';

if (s.length < min) {
const fieldNameErrorMessage =
fieldName != null ? `The length of the field ${fieldName} is too short. ` : '';

return rt.failure(
input,
context,
Expand All @@ -45,6 +45,8 @@ export const limitedArraySchema = <T extends rt.Mixed>(
}

if (s.length > max) {
const fieldNameErrorMessage =
fieldName != null ? `The length of the field ${fieldName} is too long. ` : '';
return rt.failure(
input,
context,
Expand Down

0 comments on commit c2c7d1c

Please sign in to comment.