Skip to content

Commit

Permalink
Merge 9a0d48f into c68efa3
Browse files Browse the repository at this point in the history
  • Loading branch information
mertcanyalhi committed Apr 8, 2020
2 parents c68efa3 + 9a0d48f commit f3604be
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 1 deletion.
2 changes: 1 addition & 1 deletion packages/structure/src/validation/forSchema.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,4 +45,4 @@ module.exports = function validationForSchema(schema) {
};
};

const mapDetail = ({ message, path }) => ({ message, path });
const mapDetail = ({ message, path, type }) => ({ message, path, type });
4 changes: 4 additions & 0 deletions packages/structure/test/unit/instanceAndUpdate.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,7 @@ describe('instantiating a structure', () => {
{
message: '"password" is required',
path: ['password'],
type: 'any.required',
},
];

Expand Down Expand Up @@ -388,6 +389,7 @@ describe('instantiating a structure with dynamic attribute types', () => {
{
message: '"favoriteBook.pages" must be a number',
path: ['favoriteBook', 'pages'],
type: 'number.base',
},
];

Expand Down Expand Up @@ -678,6 +680,7 @@ describe('cloning an instance', () => {
{
message: '"name" is required',
path: ['name'],
type: 'any.required',
},
];

Expand All @@ -704,6 +707,7 @@ describe('cloning an instance', () => {
{
message: '"favoriteBook.name" is required',
path: ['favoriteBook', 'name'],
type: 'any.required',
},
];

Expand Down
8 changes: 8 additions & 0 deletions packages/structure/test/unit/validation/staticMethod.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,9 @@ describe('validation', () => {
expect(errors).toBeInstanceOf(Array);
expect(errors).toHaveLength(2);
expect(errors[0].path).toEqual(['name']);
expect(errors[0].type).toEqual('any.required');
expect(errors[1].path).toEqual(['age']);
expect(errors[1].type).toEqual('number.min');
});
});

Expand All @@ -72,6 +74,7 @@ describe('validation', () => {
expect(errors).toBeInstanceOf(Array);
expect(errors).toHaveLength(1);
expect(errors[0].path).toEqual(['name']);
expect(errors[0].type).toEqual('string.base');
});
});
});
Expand Down Expand Up @@ -104,6 +107,7 @@ describe('validation', () => {
expect(errors).toBeInstanceOf(Array);
expect(errors).toHaveLength(1);
expect(errors[0].path).toEqual(['favoriteBook', 'name']);
expect(errors[0].type).toEqual('any.required');
});
});

Expand Down Expand Up @@ -136,6 +140,7 @@ describe('validation', () => {
expect(errors).toBeInstanceOf(Array);
expect(errors).toHaveLength(1);
expect(errors[0].path).toEqual(['user', 'name']);
expect(errors[0].type).toEqual('string.base');
});
});
});
Expand Down Expand Up @@ -167,7 +172,9 @@ describe('validation', () => {
expect(errors).toBeInstanceOf(Array);
expect(errors).toHaveLength(2);
expect(errors[0].path).toEqual(['name']);
expect(errors[0].type).toEqual('any.required');
expect(errors[1].path).toEqual(['age']);
expect(errors[1].type).toEqual('number.min');
});
});

Expand Down Expand Up @@ -204,6 +211,7 @@ describe('validation', () => {
expect(errors).toBeInstanceOf(Array);
expect(errors).toHaveLength(1);
expect(errors[0].path).toEqual(['user', 'name']);
expect(errors[0].type).toEqual('any.required');
});
});
});
Expand Down

0 comments on commit f3604be

Please sign in to comment.