Skip to content

Commit

Permalink
fix(vest): error message override when no warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
ealush committed Jan 12, 2021
1 parent c1bd6ab commit f59a659
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 1 deletion.
21 changes: 21 additions & 0 deletions packages/vest/src/utilities/__tests__/schema.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,27 @@ describe('schema', () => {
...res.getErrors('friends[0].name.middle'),
]);
});

it('Should return error messages when they should appear', () => {
const Name = enforce.loose({
name: enforce
.loose({
first: enforce.isString().isNotEmpty().message('first_name_error'),
last: enforce.isString().isNotEmpty().message('last_name_error'),
})
.message('name_error'),
});

const Schema = schema(Name);
const res = Schema({ name: {} });

expect(res.hasErrors()).toBe(true);
expect(res.getErrors()).toEqual({
name: ['name_error', 'first_name_error', 'last_name_error'],
'name.first': ['first_name_error'],
'name.last': ['last_name_error'],
});
});
});

const Name = enforce.loose({
Expand Down
2 changes: 1 addition & 1 deletion packages/vest/src/utilities/schema.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ export default function schema(enforceSchema) {
errorMessages[test] = parsedResult[test].errors = Object.keys(
parsedResult[test].errors
);
errorMessages[test] = parsedResult[test].warnings = Object.keys(
warningMessages[test] = parsedResult[test].warnings = Object.keys(
parsedResult[test].warnings
);
_hasErrors = _hasErrors || parsedResult[test].hasErrors;
Expand Down
1 change: 1 addition & 0 deletions scripts/release/steps/pushToLatestBranch.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ const SCRIPT_PATH = path.resolve(
filePaths.ROOT_PATH,
'scripts',
'release',
'steps',
'push_to_latest_branch.sh'
);

Expand Down

0 comments on commit f59a659

Please sign in to comment.