Ejemplo n.º 1
0
 /// <summary>
 /// Validate the object.
 /// </summary>
 /// <exception cref="ValidationException">
 /// Thrown if validation fails
 /// </exception>
 public virtual void Validate()
 {
     if (Location == null)
     {
         throw new ValidationException(ValidationRules.CannotBeNull, "Location");
     }
     if (CreationToken == null)
     {
         throw new ValidationException(ValidationRules.CannotBeNull, "CreationToken");
     }
     if (SubnetId == null)
     {
         throw new ValidationException(ValidationRules.CannotBeNull, "SubnetId");
     }
     if (FileSystemId != null)
     {
         if (FileSystemId.Length > 36)
         {
             throw new ValidationException(ValidationRules.MaxLength, "FileSystemId", 36);
         }
         if (FileSystemId.Length < 36)
         {
             throw new ValidationException(ValidationRules.MinLength, "FileSystemId", 36);
         }
         if (!System.Text.RegularExpressions.Regex.IsMatch(FileSystemId, "^[a-fA-F0-9]{8}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{12}$"))
         {
             throw new ValidationException(ValidationRules.Pattern, "FileSystemId", "^[a-fA-F0-9]{8}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{12}$");
         }
     }
     if (CreationToken != null)
     {
         if (CreationToken.Length > 80)
         {
             throw new ValidationException(ValidationRules.MaxLength, "CreationToken", 80);
         }
         if (CreationToken.Length < 1)
         {
             throw new ValidationException(ValidationRules.MinLength, "CreationToken", 1);
         }
         if (!System.Text.RegularExpressions.Regex.IsMatch(CreationToken, "^[a-zA-Z][a-zA-Z0-9\\-]{0,79}$"))
         {
             throw new ValidationException(ValidationRules.Pattern, "CreationToken", "^[a-zA-Z][a-zA-Z0-9\\-]{0,79}$");
         }
     }
     if (UsageThreshold > 109951162777600)
     {
         throw new ValidationException(ValidationRules.InclusiveMaximum, "UsageThreshold", 109951162777600);
     }
     if (UsageThreshold < 107374182400)
     {
         throw new ValidationException(ValidationRules.InclusiveMinimum, "UsageThreshold", 107374182400);
     }
     if (SnapshotId != null)
     {
         if (SnapshotId.Length > 36)
         {
             throw new ValidationException(ValidationRules.MaxLength, "SnapshotId", 36);
         }
         if (SnapshotId.Length < 36)
         {
             throw new ValidationException(ValidationRules.MinLength, "SnapshotId", 36);
         }
         if (!System.Text.RegularExpressions.Regex.IsMatch(SnapshotId, "^[a-fA-F0-9]{8}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{12}|(\\\\?([^\\/]*[\\/])*)([^\\/]+)$"))
         {
             throw new ValidationException(ValidationRules.Pattern, "SnapshotId", "^[a-fA-F0-9]{8}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{12}|(\\\\?([^\\/]*[\\/])*)([^\\/]+)$");
         }
     }
     if (BaremetalTenantId != null)
     {
         if (BaremetalTenantId.Length > 36)
         {
             throw new ValidationException(ValidationRules.MaxLength, "BaremetalTenantId", 36);
         }
         if (BaremetalTenantId.Length < 36)
         {
             throw new ValidationException(ValidationRules.MinLength, "BaremetalTenantId", 36);
         }
         if (!System.Text.RegularExpressions.Regex.IsMatch(BaremetalTenantId, "^[a-fA-F0-9]{8}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{12}$"))
         {
             throw new ValidationException(ValidationRules.Pattern, "BaremetalTenantId", "^[a-fA-F0-9]{8}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{12}$");
         }
     }
     if (MountTargets != null)
     {
         foreach (var element in MountTargets)
         {
             if (element != null)
             {
                 element.Validate();
             }
         }
     }
     if (DataProtection != null)
     {
         DataProtection.Validate();
     }
 }
 /// <summary>
 /// Validate the object.
 /// </summary>
 /// <exception cref="ValidationException">
 /// Thrown if validation fails
 /// </exception>
 public virtual void Validate()
 {
     if (CreationToken == null)
     {
         throw new ValidationException(ValidationRules.CannotBeNull, "CreationToken");
     }
     if (SubnetId == null)
     {
         throw new ValidationException(ValidationRules.CannotBeNull, "SubnetId");
     }
     if (FileSystemId != null)
     {
         if (FileSystemId.Length > 36)
         {
             throw new ValidationException(ValidationRules.MaxLength, "FileSystemId", 36);
         }
         if (FileSystemId.Length < 36)
         {
             throw new ValidationException(ValidationRules.MinLength, "FileSystemId", 36);
         }
         if (!System.Text.RegularExpressions.Regex.IsMatch(FileSystemId, "^[a-fA-F0-9]{8}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{12}$"))
         {
             throw new ValidationException(ValidationRules.Pattern, "FileSystemId", "^[a-fA-F0-9]{8}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{12}$");
         }
     }
     if (CreationToken != null)
     {
         if (CreationToken.Length > 80)
         {
             throw new ValidationException(ValidationRules.MaxLength, "CreationToken", 80);
         }
         if (CreationToken.Length < 1)
         {
             throw new ValidationException(ValidationRules.MinLength, "CreationToken", 1);
         }
         if (!System.Text.RegularExpressions.Regex.IsMatch(CreationToken, "^[a-zA-Z][a-zA-Z0-9\\-]{0,79}$"))
         {
             throw new ValidationException(ValidationRules.Pattern, "CreationToken", "^[a-zA-Z][a-zA-Z0-9\\-]{0,79}$");
         }
     }
     if (UsageThreshold > 109951162777600)
     {
         throw new ValidationException(ValidationRules.InclusiveMaximum, "UsageThreshold", 109951162777600);
     }
     if (UsageThreshold < 107374182400)
     {
         throw new ValidationException(ValidationRules.InclusiveMinimum, "UsageThreshold", 107374182400);
     }
     if (SnapshotId != null)
     {
         if (SnapshotId.Length > 36)
         {
             throw new ValidationException(ValidationRules.MaxLength, "SnapshotId", 36);
         }
         if (SnapshotId.Length < 36)
         {
             throw new ValidationException(ValidationRules.MinLength, "SnapshotId", 36);
         }
         if (!System.Text.RegularExpressions.Regex.IsMatch(SnapshotId, "^[a-fA-F0-9]{8}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{12}|(\\\\?([^\\/]*[\\/])*)([^\\/]+)$"))
         {
             throw new ValidationException(ValidationRules.Pattern, "SnapshotId", "^[a-fA-F0-9]{8}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{12}|(\\\\?([^\\/]*[\\/])*)([^\\/]+)$");
         }
     }
     if (BackupId != null)
     {
         if (BackupId.Length > 36)
         {
             throw new ValidationException(ValidationRules.MaxLength, "BackupId", 36);
         }
         if (BackupId.Length < 36)
         {
             throw new ValidationException(ValidationRules.MinLength, "BackupId", 36);
         }
         if (!System.Text.RegularExpressions.Regex.IsMatch(BackupId, "^[a-fA-F0-9]{8}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{12}|(\\\\?([^\\/]*[\\/])*)([^\\/]+)$"))
         {
             throw new ValidationException(ValidationRules.Pattern, "BackupId", "^[a-fA-F0-9]{8}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{12}|(\\\\?([^\\/]*[\\/])*)([^\\/]+)$");
         }
     }
     if (NetworkSiblingSetId != null)
     {
         if (NetworkSiblingSetId.Length > 36)
         {
             throw new ValidationException(ValidationRules.MaxLength, "NetworkSiblingSetId", 36);
         }
         if (NetworkSiblingSetId.Length < 36)
         {
             throw new ValidationException(ValidationRules.MinLength, "NetworkSiblingSetId", 36);
         }
         if (!System.Text.RegularExpressions.Regex.IsMatch(NetworkSiblingSetId, "^[a-fA-F0-9]{8}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{12}$"))
         {
             throw new ValidationException(ValidationRules.Pattern, "NetworkSiblingSetId", "^[a-fA-F0-9]{8}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{12}$");
         }
     }
     if (MountTargets != null)
     {
         foreach (var element in MountTargets)
         {
             if (element != null)
             {
                 element.Validate();
             }
         }
     }
     if (DataProtection != null)
     {
         DataProtection.Validate();
     }
     if (CoolnessPeriod != null)
     {
         if (CoolnessPeriod > 63)
         {
             throw new ValidationException(ValidationRules.InclusiveMaximum, "CoolnessPeriod", 63);
         }
         if (CoolnessPeriod < 7)
         {
             throw new ValidationException(ValidationRules.InclusiveMinimum, "CoolnessPeriod", 7);
         }
     }
     if (UnixPermissions != null)
     {
         if (UnixPermissions.Length > 4)
         {
             throw new ValidationException(ValidationRules.MaxLength, "UnixPermissions", 4);
         }
         if (UnixPermissions.Length < 4)
         {
             throw new ValidationException(ValidationRules.MinLength, "UnixPermissions", 4);
         }
     }
     if (PlacementRules != null)
     {
         foreach (var element1 in PlacementRules)
         {
             if (element1 != null)
             {
                 element1.Validate();
             }
         }
     }
 }