Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(validations): do not require min and max size validation #151

Merged
merged 4 commits into from
Nov 28, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion examples/09-validate-validations.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,5 @@ module.exports = function (migration) {
.type('Link')
.linkType('Asset')
.name('amount of calories the food contains')
.validations([{ assetImageDimensions: { width: { min: 1199, max: null }, height: { min: null, max: null } } }]);
.validations([{ assetImageDimensions: { width: { min: 1199, max: null }, height: { min: 1343 } } }]);
};
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ const validation = (name, constraint) => Joi.object({
})

const range = (type) => Joi.object({
min: Joi[type]().required().allow(null),
max: Joi[type]().required().allow(null)
min: Joi[type]().allow(null),
max: Joi[type]().allow(null)
})

const linkContentType = validation('linkContentType', Joi.array().items(Joi.string()))
Expand Down
11 changes: 2 additions & 9 deletions test/end-to-end/validations.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ describe('apply validations migration examples', function () {
disabled: false,
localized: false,
omitted: false,
validations: [{ assetImageDimensions: { width: { min: 1199, max: null }, height: { min: null, max: null } } }]
validations: [{ assetImageDimensions: { width: { min: 1199, max: null }, height: { min: 1343 } } }]
}
];

Expand All @@ -66,19 +66,12 @@ describe('apply validations migration examples', function () {
.on(/\? Do you want to apply the migration \(Y\/n\)/).respond('y\n')
.expect(assert.plans.contentType.create('dieatary-food', { name: 'Dieatary Food', description: 'Food with up to 500 calories' }))
.expect(assert.plans.field.create('name', { type: 'Symbol', name: 'name of the food', validations: [{ unique: true }] }))
.expect(assert.plans.field.create('calories', { type: 'Link', linkType: 'Asset', name: 'amount of calories the food contains', validations: [{ assetImageDimensions: { width: { min: 1199, max: null }, height: { min: null, max: null } } }] }))
.expect(assert.plans.field.create('calories', { type: 'Link', linkType: 'Asset', name: 'amount of calories the food contains', validations: [{ assetImageDimensions: { width: { min: 1199, max: null }, height: { min: 1343 } } }] }))
.expect(assert.plans.actions.apply())
.end(co(function * () {
const contentType = yield getDevContentType(SOURCE_TEST_SPACE, environmentId, 'dieatary-food');
expect(contentType.fields).to.eql(expectedFields);
done();
}));
});

it('attempts to apply 19-bad-validations migration and fails', function (done) {
cli()
.run(`--space-id ${SOURCE_TEST_SPACE} --environment-id ${environmentId} ./examples/19-bad-validations.js`)
.stderr(/The property "validations.0.assetImageDimensions.width.max" is required on the field "assetTest"./)
.end(done);
});
});
Empty file removed test/fixtures/.gitkeep
Empty file.
Loading