IsValidPackageId() public static method

public static IsValidPackageId ( string packageId ) : bool
packageId string
return bool
        public IEnumerable <ValidationResult> Validate(ValidationContext validationContext)
        {
            if (!String.IsNullOrEmpty(Id))
            {
                if (Id.Length > PackageIdValidator.MaxPackageIdLength)
                {
                    yield return(new ValidationResult(String.Format(CultureInfo.CurrentCulture, NuGetResources.Manifest_IdMaxLengthExceeded)));
                }
                else if (!PackageIdValidator.IsValidPackageId(Id))
                {
                    yield return(new ValidationResult(String.Format(CultureInfo.CurrentCulture, NuGetResources.InvalidPackageId, Id)));
                }
            }

            if (LicenseUrl == String.Empty)
            {
                yield return(new ValidationResult(
                                 String.Format(CultureInfo.CurrentCulture, NuGetResources.Manifest_UriCannotBeEmpty, "LicenseUrl")));
            }

            if (IconUrl == String.Empty)
            {
                yield return(new ValidationResult(
                                 String.Format(CultureInfo.CurrentCulture, NuGetResources.Manifest_UriCannotBeEmpty, "IconUrl")));
            }

            if (ProjectUrl == String.Empty)
            {
                yield return(new ValidationResult(
                                 String.Format(CultureInfo.CurrentCulture, NuGetResources.Manifest_UriCannotBeEmpty, "ProjectUrl")));
            }

            if (RequireLicenseAcceptance && String.IsNullOrWhiteSpace(LicenseUrl))
            {
                yield return(new ValidationResult(NuGetResources.Manifest_RequireLicenseAcceptanceRequiresLicenseUrl));
            }
        }
示例#2
0
 public IEnumerable <ValidationResult> Validate(ValidationContext validationContext)
 {
     if (!string.IsNullOrEmpty(this.Id))
     {
         if (this.Id.Length > 100)
         {
             yield return(new ValidationResult(string.Format(CultureInfo.CurrentCulture, NuGetResources.Manifest_IdMaxLengthExceeded, new object[0])));
         }
         else if (!PackageIdValidator.IsValidPackageId(this.Id))
         {
             object[] args = new object[] { this.Id };
             yield return(new ValidationResult(string.Format(CultureInfo.CurrentCulture, NuGetResources.InvalidPackageId, args)));
         }
     }
     if (this.LicenseUrl == string.Empty)
     {
         object[] args = new object[] { "LicenseUrl" };
         yield return(new ValidationResult(string.Format(CultureInfo.CurrentCulture, NuGetResources.Manifest_UriCannotBeEmpty, args)));
     }
     if (this.IconUrl == string.Empty)
     {
         object[] args = new object[] { "IconUrl" };
         yield return(new ValidationResult(string.Format(CultureInfo.CurrentCulture, NuGetResources.Manifest_UriCannotBeEmpty, args)));
     }
     if (this.ProjectUrl == string.Empty)
     {
         object[] args = new object[] { "ProjectUrl" };
         yield return(new ValidationResult(string.Format(CultureInfo.CurrentCulture, NuGetResources.Manifest_UriCannotBeEmpty, args)));
     }
     while (true)
     {
         if (this.RequireLicenseAcceptance && string.IsNullOrWhiteSpace(this.LicenseUrl))
         {
             yield return(new ValidationResult(NuGetResources.Manifest_RequireLicenseAcceptanceRequiresLicenseUrl));
         }
     }
 }