Too Many Returns
Example
const Validator = require('validator')
const _ = require('lodash')
module.exports = class {
validate({imageUrl, proxy, useProxy, width, height, keepRatio, quality}) {
if (!Validator.isURL(imageUrl) && !imageUrl.startsWith('data:image')) {
return 'imageUrl needs to be a valid URL'
}
if (proxy && useProxy) {
if (!Validator.isURL(proxy)) {
return 'proxy needs to be a valid URL'
}
if (!_.isBoolean(useProxy)) {
return 'useProxy needs to be a boolean'
}
}
if (!_.isNumber(width)) {
return 'width needs to be a number'
}
if (!_.isNumber(height)) {
return 'height needs to be a number'
}
if (!_.isBoolean(keepRatio)) {
return 'keepRatio needs to be a boolean'
}
if (quality) {
if (!_.isNumber(quality)) {
return 'quality needs to be a number'
}
}
}
}Last updated