diff --git a/core/server/api/shared/pipeline.js b/core/server/api/shared/pipeline.js index 1ea6490661f4..a37af2a5eb10 100644 --- a/core/server/api/shared/pipeline.js +++ b/core/server/api/shared/pipeline.js @@ -12,8 +12,8 @@ const STAGES = { * * We call the shared validator which runs the request through: * - * 1. Shared serializers - * 2. Custom API serializers + * 1. Shared validator + * 2. Custom API validators * * @param {Object} apiUtils - Local utils of target API version. * @param {Object} apiConfig - Docname & Method of ctrl. diff --git a/core/server/api/v2/oembed.js b/core/server/api/v2/oembed.js index e7dff7cfa5c0..4efd21df4c1f 100644 --- a/core/server/api/v2/oembed.js +++ b/core/server/api/v2/oembed.js @@ -44,12 +44,6 @@ module.exports = { query({data}) { let {url} = data; - if (!url || !url.trim()) { - return Promise.reject(new common.errors.BadRequestError({ - message: common.i18n.t('errors.api.oembed.noUrlProvided') - })); - } - function unknownProvider() { return Promise.reject(new common.errors.ValidationError({ message: common.i18n.t('errors.api.oembed.unknownProvider'), diff --git a/core/server/api/v2/utils/validators/input/index.js b/core/server/api/v2/utils/validators/input/index.js index ade462c797bd..e028d441d078 100644 --- a/core/server/api/v2/utils/validators/input/index.js +++ b/core/server/api/v2/utils/validators/input/index.js @@ -37,5 +37,9 @@ module.exports = { get images() { return require('./images'); + }, + + get oembed() { + return require('./oembed'); } }; diff --git a/core/server/api/v2/utils/validators/input/oembed.js b/core/server/api/v2/utils/validators/input/oembed.js new file mode 100644 index 000000000000..9ebbf25a766b --- /dev/null +++ b/core/server/api/v2/utils/validators/input/oembed.js @@ -0,0 +1,12 @@ +const Promise = require('bluebird'); +const common = require('../../../../../lib/common'); + +module.exports = { + read(apiConfig, frame) { + if (!frame.data.url || !frame.data.url.trim()) { + return Promise.reject(new common.errors.BadRequestError({ + message: common.i18n.t('errors.api.oembed.noUrlProvided') + })); + } + } +};