function validateDeviceConfig({ deviceConfig, errorComposer, deviceAlias }) {
  if (!deviceConfig.type) {
    throw errorComposer.missingDeviceType(deviceAlias);
  }

  const maybeError = _.attempt(() => environmentFactory.validateConfig(deviceConfig));
  if (_.isError(maybeError)) {
      throw errorComposer.invalidDeviceType(deviceAlias, deviceConfig, maybeError);
  }

  if (!KNOWN_TYPES.has(deviceConfig.type)) {
    return;
  }

  if (deviceConfig.bootArgs != null) {
    if (!_.isString(deviceConfig.bootArgs)) {
      throw errorComposer.malformedDeviceProperty(deviceAlias, 'bootArgs');
    }

    if (deviceConfig.type !== 'ios.simulator' && deviceConfig.type !== 'android.emulator') {
      throw errorComposer.unsupportedDeviceProperty(deviceAlias, 'bootArgs');
    }
  }

  if (deviceConfig.utilBinaryPaths != null) {
    if (!Array.isArray(deviceConfig.utilBinaryPaths)) {
      throw errorComposer.malformedDeviceProperty(deviceAlias, 'utilBinaryPaths');
    }

    if (deviceConfig.utilBinaryPaths.some(s => !_.isString(s))) {
      throw errorComposer.malformedDeviceProperty(deviceAlias, 'utilBinaryPaths');
    }

    if (!deviceConfig.type.match(/^android\.(attached|emulator|genycloud)$/)) {
      throw errorComposer.unsupportedDeviceProperty(deviceAlias, 'utilBinaryPaths');
    }
  }

  if (deviceConfig.forceAdbInstall !== undefined) {
    if (!_.isBoolean(deviceConfig.forceAdbInstall)) {
      throw errorComposer.malformedDeviceProperty(deviceAlias, 'forceAdbInstall');
    }

    if (!deviceConfig.type.match(/^android\.(attached|emulator|genycloud)$/)) {
      throw errorComposer.unsupportedDeviceProperty(deviceAlias, 'forceAdbInstall');
    }
  }

  if (deviceConfig.gpuMode !== undefined) {
    if (!_.isString(deviceConfig.gpuMode)) {
      throw errorComposer.malformedDeviceProperty(deviceAlias, 'gpuMode');
    }

    if (!deviceConfig.gpuMode.match(/^(auto|host|swiftshader_indirect|angle_indirect|guest|off)$/)) {
      throw errorComposer.malformedDeviceProperty(deviceAlias, 'gpuMode');
    }

    if (deviceConfig.type !== 'android.emulator') {
      throw errorComposer.unsupportedDeviceProperty(deviceAlias, 'gpuMode');
    }
  }

  if (deviceConfig.headless !== undefined) {
    if (!_.isBoolean(deviceConfig.headless)) {
      throw errorComposer.malformedDeviceProperty(deviceAlias, 'headless');
    }

    if (deviceConfig.type !== 'ios.simulator' && deviceConfig.type !== 'android.emulator') {
      throw errorComposer.unsupportedDeviceProperty(deviceAlias, 'headless');
    }
  }

  if (deviceConfig.readonly !== undefined) {
    if (!_.isBoolean(deviceConfig.readonly)) {
      throw errorComposer.malformedDeviceProperty(deviceAlias, 'readonly');
    }

    if (deviceConfig.type !== 'android.emulator') {
      throw errorComposer.unsupportedDeviceProperty(deviceAlias, 'readonly');
    }
  }

  if (_.isObject(deviceConfig.device)) {
    const expectedProperties = EXPECTED_DEVICE_MATCHER_PROPS[deviceConfig.type];
    /* istanbul ignore else */
    if (!_.isEmpty(expectedProperties)) {
      const minimalShape = _.pick(deviceConfig.device, expectedProperties);

      if (_.isEmpty(minimalShape)) {
        throw errorComposer.missingDeviceMatcherProperties(deviceAlias, expectedProperties);
      }
    }
  }
}
@param {DetoxConfigErrorComposer} errorComposer
@param {Detox.DetoxDeviceConfig} deviceConfig
@param {String | undefined} deviceAlias