public ExporterValidationResults Validate(ProductCatalogItem item)
        {
            var results = new ExporterValidationResults();

            if (string.IsNullOrEmpty(item.id))
            {
                results.fieldErrors["id"] = "ID field is required for cloud upload";
            }

            if (string.IsNullOrEmpty(item.defaultDescription.Title))
            {
                results.fieldErrors["defaultDescription.Title"] = "Title is required for cloud upload";
            }

            if (item.googlePrice.value < 0)
            {
                results.fieldErrors["googlePrice"] = "Google price cannot be less than 0";
            }

            if (item.googlePrice.value > kMaxGooglePrice)
            {
                results.fieldErrors["googlePrice"] = string.Format("Google price cannot be greater than {0}", kMaxGooglePrice);
            }

            return(results);
        }
        public ExporterValidationResults Validate(ProductCatalogItem item)
        {
            var results = new ExporterValidationResults();

            // Check for missing IDs
            if (string.IsNullOrEmpty(item.id))
            {
                results.fieldErrors["id"] = "ID is required";
            }

            // Check for missing title
            if (string.IsNullOrEmpty(item.defaultDescription.Title))
            {
                results.fieldErrors["defaultDescription.Title"] = "Title is required";
            }

            // Check for missing description
            if (string.IsNullOrEmpty(item.defaultDescription.Description))
            {
                results.fieldErrors["defaultDescription.Description"] = "Description is required";
            }

            // Check for screenshot
            if (string.IsNullOrEmpty(item.screenshotPath))
            {
                results.fieldErrors["screenshotPath"] = "Screenshot is required";
            }
            else
            {
                kFilesToCopy.Add(item.screenshotPath);
            }

            return(results);
        }
Esempio n. 3
0
        public ExporterValidationResults Validate(ProductCatalog catalog)
        {
            var results = new ExporterValidationResults();

            // Warn if exporting an empty catalog
            if (catalog.allProducts.Count == 0)
            {
                results.warnings.Add("Catalog is empty");
            }

            // Check for duplicate IDs
            var usedIDs = new HashSet <string>();

            foreach (var product in catalog.allProducts)
            {
                if (usedIDs.Contains(product.id))
                {
                    results.errors.Add("More than one product uses the ID \"" + product.id + "\"");
                }
                usedIDs.Add(product.id);
            }

            // Check for duplicate store IDs
            var usedStoreIDs = new HashSet <string>();

            foreach (var product in catalog.allProducts)
            {
                var storeID = product.GetStoreID(GooglePlay.Name);
                if (!string.IsNullOrEmpty(storeID))
                {
                    if (usedStoreIDs.Contains(storeID))
                    {
                        results.errors.Add("More than one product uses the Google Play store ID \"" + storeID + "\"");
                    }
                    usedStoreIDs.Add(product.id);
                }
            }

            // Check for duplicate runtime IDs -- this conflict could occur if a product has a base ID that is the
            // same as another product's store-specific ID
            var runtimeIDs = new HashSet <string>();

            foreach (var product in catalog.allProducts)
            {
                var runtimeID = product.GetStoreID(GooglePlay.Name);
                if (string.IsNullOrEmpty(runtimeID))
                {
                    runtimeID = product.id;
                }

                if (runtimeIDs.Contains(runtimeID))
                {
                    results.errors.Add("More than one product is identified by the ID \"" + runtimeID + "\"");
                }
                runtimeIDs.Add(runtimeID);
            }

            return(results);
        }
Esempio n. 4
0
        public ExporterValidationResults Validate(ProductCatalogItem item)
        {
            var results = new ExporterValidationResults();

            // Check for missing IDs
            if (string.IsNullOrEmpty(item.id))
            {
                results.errors.Add("ID is required");
            }

            // A product ID must start with a lowercase letter or a number and must be composed
            // of only lowercase letters (a-z), numbers (0-9), underscores (_), and periods (.)
            string actualID = item.GetStoreID(GooglePlay.Name) ?? item.id;
            string field    = (actualID == item.GetStoreID(GooglePlay.Name)) ? "storeID." + GooglePlay.Name : "id";

            if (Char.IsNumber(actualID[0]) || (Char.IsLower(actualID[0]) && Char.IsLetter(actualID[0])))
            {
                foreach (char c in actualID)
                {
                    if (c != '_' && c != '.' && !Char.IsNumber(c) && !(Char.IsLetter(c) && Char.IsLower(c)))
                    {
                        results.fieldErrors[field] = "Product ID \"" + actualID + "\" must contain only lowercase letters, numbers, underscores, and periods";
                    }
                }
            }
            else
            {
                results.fieldErrors[field] = "Product ID \"" + actualID + "\" must start with a lowercase letter or a number";
            }

            ValidateDescription(item.defaultDescription, ref results, "defaultDescription");
            foreach (var desc in item.translatedDescriptions)
            {
                ValidateDescription(desc, ref results);
            }

            // Check for missing price information
            if (string.IsNullOrEmpty(item.pricingTemplateID) && item.googlePrice.value == 0)
            {
                results.fieldErrors["googlePrice"] = "Items must have either a price or a pricing template ID";
            }

            return(results);
        }
Esempio n. 5
0
        private void ValidateDescription(LocalizedProductDescription desc, ref ExporterValidationResults results, string fieldPrefix = null)
        {
            if (fieldPrefix == null)
            {
                fieldPrefix = "translatedDescriptions." + desc.googleLocale.ToString();
            }

            // Check for missing title
            if (string.IsNullOrEmpty(desc.Title))
            {
                results.fieldErrors[fieldPrefix + ".Title"] = "Title is required (" + desc.googleLocale.ToString() + ")";
            }
            else
            {
                if (desc.Title.Length > 55)                   // Titles can be up to 55 characters in length
                {
                    results.fieldErrors[fieldPrefix + ".Title"] = "Title must not be longer than 55 characters (" + desc.googleLocale.ToString() + ")";
                }
                else if (desc.Title.Length > 25)                     // Titles should be no longer than 25 characters
                {
                    results.warnings.Add("Title should not be longer than 25 characters (" + desc.googleLocale.ToString() + ")");
                }
            }

            // Check for missing description
            if (string.IsNullOrEmpty(desc.Description))
            {
                results.fieldErrors[fieldPrefix + ".Description"] = "Description is required (" + desc.googleLocale.ToString() + ")";
            }
            else
            {
                if (desc.Description.Length > 80)                   // Descriptions can be up to 80 characters in length
                {
                    results.fieldErrors[fieldPrefix + ".Description"] = "Description must not be longer than 80 characters (" + desc.googleLocale.ToString() + ")";
                }
            }
        }
        public ExporterValidationResults Validate(ProductCatalog catalog)
        {
            var results = new ExporterValidationResults();

            // Warn if exporting an empty catalog
            if (catalog.allProducts.Count == 0)
            {
                results.warnings.Add("Catalog is empty");
            }

            // Check for duplicate IDs
            var usedIds = new HashSet <string>();

            foreach (var product in catalog.allProducts)
            {
                if (usedIds.Contains(product.id))
                {
                    results.errors.Add("More than one product uses the ID \"" + product.id + "\"");
                }
                usedIds.Add(product.id);
            }

            return(results);
        }
        public ExporterValidationResults Validate(ProductCatalog catalog)
        {
            var results = new ExporterValidationResults();

            // Warn if exporting an empty catalog
            if (catalog.allProducts.Count == 0)
            {
                results.warnings.Add("Catalog is empty");
            }

            // Check for duplicate IDs
            var usedIds = new HashSet <string>();

            foreach (var product in catalog.allProducts)
            {
                if (usedIds.Contains(product.id))
                {
                    results.errors.Add("More than one product uses the ID \"" + product.id + "\"");
                }
                usedIds.Add(product.id);
            }

            // Check for duplicate store IDs
            var usedStoreIds = new HashSet <string>();

            foreach (var product in catalog.allProducts)
            {
                var storeID = product.GetStoreID(AppleAppStore.Name);
                if (!string.IsNullOrEmpty(storeID))
                {
                    if (usedStoreIds.Contains(storeID))
                    {
                        results.errors.Add("More than one product uses the Apple store ID \"" + storeID + "\"");
                    }
                    usedIds.Add(product.id);
                }
            }

            // Check for duplicate runtime IDs -- this conflict could occur if a product has a base ID that is the
            // same as another product's store-specific ID
            var runtimeIDs = new HashSet <string>();

            foreach (var product in catalog.allProducts)
            {
                var runtimeID = product.GetStoreID(AppleAppStore.Name) ?? product.id;
                if (runtimeIDs.Contains(runtimeID))
                {
                    results.errors.Add("More than one product is identified by the ID \"" + runtimeID + "\"");
                }
                runtimeIDs.Add(runtimeID);
            }

            // Check SKU
            if (string.IsNullOrEmpty(catalog.appleSKU))
            {
                results.fieldErrors["appleSKU"] = "Apple SKU is required. Find this in iTunesConnect.";
            }
            else
            {
                kMandatoryExportFolder = catalog.appleSKU + ".itmsp";
            }

            // Check Team ID
            if (string.IsNullOrEmpty(catalog.appleTeamID))
            {
                results.fieldErrors["appleTeamID"] = "Apple Team ID is required. Find this on https://developer.apple.com.";
            }

            return(results);
        }