function _validateCorsXml(rules) {
    const cors = [];
    let result;

    if (rules.length > 100) {
        return errorInstances.InvalidRequest
            .customizeDescription(customizedErrs.numberRules);
    }
    for (let i = 0; i < rules.length; i++) {
        const rule = rules[i];
        const corsRule = {};

        result = _validator.validateOriginAndMethodExist(rule.AllowedMethod,
            rule.AllowedOrigin);
        if (result instanceof Error) {
            return result;
        }

        result = _validator.validateMethods(rule.AllowedMethod);
        if (result instanceof Error) {
            return result;
        }
        corsRule.allowedMethods = rule.AllowedMethod;

        result = _validator.validateAllowedOriginsOrHeaders(rule.AllowedOrigin,
            'AllowedOrigin');
        if (result instanceof Error) {
            return result;
        }
        corsRule.allowedOrigins = rule.AllowedOrigin;

        result = _validator.validateID(rule.ID);
        if (result instanceof Error) {
            return result;
        } else if (result) {
            corsRule.id = rule.ID[0];
        }

        result = _validator.validateAllowedHeaders(rule.AllowedHeader);
        if (result instanceof Error) {
            return result;
        } else if (result) {
            corsRule.allowedHeaders = rule.AllowedHeader;
        }

        result = _validator.validateMaxAgeSeconds(rule.MaxAgeSeconds);
        if (result instanceof Error) {
            return result;
        } else if (result) {
            corsRule.maxAgeSeconds = result;
        }

        result = _validator.validateExposeHeaders(rule.ExposeHeader);
        if (result instanceof Error) {
            return result;
        } else if (result) {
            corsRule.exposeHeaders = rule.ExposeHeader;
        }

        cors.push(corsRule);
    }
    return cors;
}
_validateCorsXml - Validate XML, returning an error if any part is not valid
@param {object[]} rules - CORSRule collection parsed from xml to be validated
@param {string[]} [rules[].ID] - optional id to identify rule
@param {string[]} rules[].AllowedMethod - methods allowed for CORS
@param {string[]} rules[].AllowedOrigin - origins allowed for CORS
@param {string[]} [rules[].AllowedHeader] - headers allowed in an OPTIONS
request via the Access-Control-Request-Headers header
@param {string[]} [rules[].MaxAgeSeconds] - seconds browsers should cache
OPTIONS response
@param {string[]} [rules[].ExposeHeader] - headers exposed to applications
@return {(Error|object)} - return cors object on success; error on failure