private void PerformValidation()
        {
            var canBuildCompleteName = true;

            if (!PackageValidation.ValidateOrganizationName(m_OrganizationName.stringValue) && !string.IsNullOrWhiteSpace(m_OrganizationName.stringValue))
            {
                canBuildCompleteName = false;
                errorMessages.Add($"Invalid Package Organization Name '{m_OrganizationName.stringValue}'");
            }
            if (!PackageValidation.ValidateName(m_Name.stringValue))
            {
                canBuildCompleteName = false;
                errorMessages.Add($"Invalid Package Name '{m_Name.stringValue}'");
            }
            if (canBuildCompleteName)
            {
                var completePackageName = BuildCompletePackageName(packageState.info.packageName.domain, m_OrganizationName.stringValue, m_Name.stringValue);
                if (!PackageValidation.ValidateCompleteName(completePackageName))
                {
                    errorMessages.Add($"Invalid Complete Package Name '{completePackageName}'");
                }
            }

            ValidateVersion(null, m_Version.stringValue, errorMessages, warningMessages);

            if (m_UnityVersionEnabled.boolValue)
            {
                if (!PackageValidation.ValidateUnityVersion(m_UnityMajor.stringValue, m_UnityMinor.stringValue,
                                                            m_UnityRelease.stringValue))
                {
                    var unityVersion = string.Join(".", new[] { m_UnityMajor.stringValue, m_UnityMinor.stringValue });
                    if (!string.IsNullOrWhiteSpace(m_UnityRelease.stringValue))
                    {
                        unityVersion += "." + m_UnityRelease.stringValue.Trim();
                    }

                    errorMessages.Add($"Invalid Unity Version '{unityVersion}'");
                }
            }

            if (string.IsNullOrWhiteSpace(m_DisplayName.stringValue) || m_DisplayName.stringValue.Trim().Length == 0)
            {
                warningMessages.Add("Display name should be provided.");
            }

            if (string.IsNullOrWhiteSpace(m_Description.stringValue) || m_Description.stringValue.Trim().Length == 0)
            {
                warningMessages.Add("Package description should be provided.");
            }

            if ((PackageVisibility)m_Visibility.intValue == PackageVisibility.AlwaysHidden)
            {
                warningMessages.Add("This package and all its assets will be hidden by default in Editor because its visibility is set to 'Always Hidden'");
            }
            if ((PackageVisibility)m_Visibility.intValue == PackageVisibility.AlwaysVisible)
            {
                warningMessages.Add("This package and all its assets will be visible by default in Editor because its visibility is set to 'Always Visible'");
            }
        }
Пример #2
0
        private void PerformValidation()
        {
            if (!PackageValidation.ValidateOrganizationName(m_OrganizationName.stringValue) && !IsNullOrEmptyTrim(m_OrganizationName.stringValue))
            {
                errorMessages.Add($"Invalid Package Organization Name '{m_OrganizationName.stringValue}'");
            }

            if (!PackageValidation.ValidateName(m_Name.stringValue))
            {
                errorMessages.Add($"Invalid Package Name '{m_Name.stringValue}'");
            }

            if (!PackageValidation.ValidateVersion(m_Version.stringValue))
            {
                errorMessages.Add($"Invalid Version '{m_Version.stringValue}'");
            }

            if (m_UnityVersionEnabled.boolValue)
            {
                if (!PackageValidation.ValidateUnityVersion(m_UnityMajor.stringValue, m_UnityMinor.stringValue,
                                                            m_UnityRelease.stringValue))
                {
                    var unityVersion = string.Join(".", new[] { m_UnityMajor.stringValue, m_UnityMinor.stringValue });
                    if (!IsNullOrEmptyTrim(m_UnityRelease.stringValue))
                    {
                        unityVersion += "." + m_UnityRelease.stringValue.Trim();
                    }

                    errorMessages.Add($"Invalid Unity Version '{unityVersion}'");
                }
            }

            if (IsNullOrEmptyTrim(m_DisplayName.stringValue) || m_DisplayName.stringValue.Trim().Length == 0)
            {
                warningMessages.Add("Display name should be provided.");
            }

            if (IsNullOrEmptyTrim(m_Description.stringValue) || m_Description.stringValue.Trim().Length == 0)
            {
                warningMessages.Add("Package description should be provided.");
            }

            if ((PackageVisibility)m_Visibility.intValue == PackageVisibility.AlwaysHidden)
            {
                warningMessages.Add("This package and all its assets will be hidden by default in Editor because its visibility is set to 'Always Hidden'");
            }
            if ((PackageVisibility)m_Visibility.intValue == PackageVisibility.AlwaysVisible)
            {
                warningMessages.Add("This package and all its assets will be visible by default in Editor because its visibility is set to 'Always Visible'");
            }
            else
            {
                if (IsNullOrEmptyTrim(packageState.info.type))
                {
                    warningMessages.Add("This package and all its assets will be hidden by default in Editor because its type is empty");
                }
                else if (PackageInfo.GetPredefinedHiddenByDefaultPackageTypes().Contains(packageState.info.type))
                {
                    warningMessages.Add($"This package and all its assets will be hidden by default in Editor because its type is '{packageState.info.type}'");
                }
                else
                {
                    warningMessages.Add($"This package and all its assets will be visible by default in Editor because its type is '{packageState.info.type}'");
                }
            }
        }