How to use the is_js.inArray function in is_js

To help you get started, we’ve selected a few is_js examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github fernando-mc / serverless-finch / lib / validate.js View on Github external
`Failed to read and/or parse specified policy. Make sure it is valid JSON.`
      );
    }
  }

  // check website configuration options

  // if redirectAllRequestsTo specified, no other website options can be specified
  // https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-s3-websiteconfiguration.html
  if (options.redirectAllRequestsTo) {
    const clientConfigOptions = Object.keys(options);
    if (is.inArray('indexDocument', clientConfigOptions)) {
      validationErrors.push('indexDocument cannot be specified with redirectAllRequestsTo');
    }

    if (is.inArray('errorDocument', clientConfigOptions)) {
      validationErrors.push('errorDocument cannot be specified with redirectAllRequestsTo');
    }

    if (is.inArray('routingRules', clientConfigOptions)) {
      validationErrors.push('routingRules cannot be specified with redirectAllRequestsTo');
    }

    if (!is.existy(options.redirectAllRequestsTo.hostName)) {
      validationErrors.push(
        'redirectAllRequestsTo.hostName is required if redirectAllRequestsTo is specified'
      );
    }
    if (!is.string(options.redirectAllRequestsTo.hostName)) {
      validationErrors.push('redirectAllRequestsTo.hostName must be a string');
    }
github fernando-mc / serverless-finch / lib / validate.js View on Github external
try {
      JSON.parse(fs.readFileSync(options.bucketPolicyFile));
    } catch (e) {
      validationErrors.push(
        `Failed to read and/or parse specified policy. Make sure it is valid JSON.`
      );
    }
  }

  // check website configuration options

  // if redirectAllRequestsTo specified, no other website options can be specified
  // https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-s3-websiteconfiguration.html
  if (options.redirectAllRequestsTo) {
    const clientConfigOptions = Object.keys(options);
    if (is.inArray('indexDocument', clientConfigOptions)) {
      validationErrors.push('indexDocument cannot be specified with redirectAllRequestsTo');
    }

    if (is.inArray('errorDocument', clientConfigOptions)) {
      validationErrors.push('errorDocument cannot be specified with redirectAllRequestsTo');
    }

    if (is.inArray('routingRules', clientConfigOptions)) {
      validationErrors.push('routingRules cannot be specified with redirectAllRequestsTo');
    }

    if (!is.existy(options.redirectAllRequestsTo.hostName)) {
      validationErrors.push(
        'redirectAllRequestsTo.hostName is required if redirectAllRequestsTo is specified'
      );
    }
github fernando-mc / serverless-finch / lib / validate.js View on Github external
// check website configuration options

  // if redirectAllRequestsTo specified, no other website options can be specified
  // https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-s3-websiteconfiguration.html
  if (options.redirectAllRequestsTo) {
    const clientConfigOptions = Object.keys(options);
    if (is.inArray('indexDocument', clientConfigOptions)) {
      validationErrors.push('indexDocument cannot be specified with redirectAllRequestsTo');
    }

    if (is.inArray('errorDocument', clientConfigOptions)) {
      validationErrors.push('errorDocument cannot be specified with redirectAllRequestsTo');
    }

    if (is.inArray('routingRules', clientConfigOptions)) {
      validationErrors.push('routingRules cannot be specified with redirectAllRequestsTo');
    }

    if (!is.existy(options.redirectAllRequestsTo.hostName)) {
      validationErrors.push(
        'redirectAllRequestsTo.hostName is required if redirectAllRequestsTo is specified'
      );
    }
    if (!is.string(options.redirectAllRequestsTo.hostName)) {
      validationErrors.push('redirectAllRequestsTo.hostName must be a string');
    }

    if (options.redirectAllRequestsTo.protocol) {
      if (!is.string(options.redirectAllRequestsTo.protocol)) {
        validationErrors.push('redirectAllRequestsTo.protocol must be a string');
      }
github fernando-mc / serverless-finch / lib / validate.js View on Github external
}

    if (!is.existy(options.redirectAllRequestsTo.hostName)) {
      validationErrors.push(
        'redirectAllRequestsTo.hostName is required if redirectAllRequestsTo is specified'
      );
    }
    if (!is.string(options.redirectAllRequestsTo.hostName)) {
      validationErrors.push('redirectAllRequestsTo.hostName must be a string');
    }

    if (options.redirectAllRequestsTo.protocol) {
      if (!is.string(options.redirectAllRequestsTo.protocol)) {
        validationErrors.push('redirectAllRequestsTo.protocol must be a string');
      }
      if (!is.inArray(options.redirectAllRequestsTo.protocol.toLowerCase(), ['http', 'https'])) {
        validationErrors.push('redirectAllRequestsTo.protocol must be either http or https');
      }
    }
  }

  if (options.routingRules) {
    if (!is.array(options.routingRules)) {
      validationErrors.push('routingRules must be a list');
    }

    options.routingRules.forEach(r => {
      if (!is.existy(r.redirect)) {
        validationErrors.push('redirect must be specified for each member of routingRules');
      }

      if (is.existy(r.redirect.replaceKeyPrefixWith) && is.existy(r.redirect.replaceKeyWith)) {
github Albert-Gao / veasy / src / normalHandlers.js View on Github external
export function enumHandler(value, schema) {
  const isValid = is.inArray(value, schema.enum);
  if (isValid) return;

  const errorText = `Value of ${NAME_PLACEHOLDER} should be within [${schema.enum.toString()}].`;
  throwError(value, errorText);
}
github Albert-Gao / veasy / src / ruleHandlers / generalRules.js View on Github external
export const inArray = (name, value, schema) => ({
  isValid: is.inArray(value, schema.inArray),
  errorText: `Value of ${name} should be within [${schema.inArray.toString()}].`
});